The add operation is used to add a database server of the specified type to Plesk. Before adding the database server, make sure the database server type is supported by Plesk. For more information, refer to the Managing Database Server section.

Request Packet Structure

A request XML packet adding a database server includes the add operation node:

<packet>
<db_server>
  <add>
  ...
  </add>
</db_server>
</packet>

The add node is presented by type DatabaseServerAddParam (plesk_db.xsd), and its graphical representation is as follows:

image 37580

Note: The interactive schema navigator for all request packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_input.svg.

  • The host node is required. It specifies the IP address or name of the database server you want to add. Data type: string.
  • The port node is required. It specifies the port of the database server. Data type: string.
  • The type node is required. It specifies the database server type. Data type: string. Allowed values: mysql | postgresql | mssql.
  • The admin node is required. It specifies the login name of administrator of the database server. Data type: integer.
  • The password node is optional. It specifies the password of administrator of the database server. Data type: integer.
  • The default node is optional. It specifies if the database server manages the databases of a certain type (defined by type). Data type: none.

Remarks

You can add multiple database servers in a single packet. Add as many add operations as the number of database servers you want to add.

<db_server>
   <add>
   ...
   </add>
...
   <add>
   ...
   </add>
</db_server>

Note: When creating request packets, put nodes and elements in the order they follow in the packet structure.

Response Packet Structure

The add node of the output XML packet is structured as follows:

image 37581

Note: The interactive schema navigator for all response packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_output.svg.

  • The result node is required. It wraps the response retrieved from the server. Data type: DatabaseServerResultType (database_output.xsd).
  • The status node is required. It specifies the execution status of the add operation. Data type: string. Allowed values: ok | error.
  • The errcode node is optional. Is returns the error code if the add operation fails. Data type: integer.
  • The errtext node is optional. It returns the error message if the add operation fails. Data type: string.
  • The id node is optional. If the add operation succeeds, it returns the ID of the database server. Data type: integer.

Samples

Adding a single database server

This request packet adds the local MySQL database server.

<packet>
<db_server>
 <add>
   <host>localhost</host>
   <port>3306</port>
   <type>mysql</type>
   <admin>senior</admin>
   <password>senior</password>
 </add>
</db_server>
</packet>

Response:

<packet>
<db_server>
 <add>
   <result>
   <status>ok</status>
   <id>15</id>
   </result>
 </add>
</db_server>
</packet>

If the type of database server is not supported by Plesk, the response looks as follows:

<packet>
<db_server>
 <add>
   <result>
    <status>error</status>
    <errcode>14008</errcode>
    <errtext>Wrong database server type</errtext>
   </result>
 </add>
</db_server>
</packet>

If the local MySQL database server already exists in Plesk, the response looks as follows:

<packet>
<db_server>
 <add>
   <result>
    <status>error</status>
    <errcode>1023</errcode>
    <errtext>Operation failed</errtext>
   </result>
 </add>
</db_server>
</packet>