Changing Credentials, Access Rules, and User Roles
The set-db-user operation is used for changing credentials of a database user, specifying access control records for MySQL databases, restricting access to databases by IP addresses, and granting pre-defined roles to database users.
Request Packet Structure
A request XML packet changing database user settings includes the set-db-users operation node:
<packet>
<database>
<set-db-user>
...
</set-db-user>
</database>
</packet>
The set-db-user node is presented by type
DatabaseSetDBUserInputType (database_input.xsd
), and its graphical
representation is as follows:
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 id node is required. It specifies the ID of the database user whose preferences are to be changed. Data type: integer.
- The login node is optional. It specifies new login name for the database user. Data type: string.
- The password node is required. It specifies new password for the database user. Data type: string (length should be more than five digits).
- The password-type node is optional. It specifies whether it is
a plain or encrypted password. Data type: string. Allowed values:
plain
|crypt
. - The acl node is optional. It specifies the hosts from which a database user is allowed to connect to a database. Data type: DatabaseUserAclType, which consists of host elements of the string data type.
- The allow-access-from node is optional. It specifies the IP addresses from which access to a database is allowed. Data type: DatabaseUserRemoteAccessRulesType, which consists of ip-address elements of the string data type
- The role node is optional. It specifies the database user role.
Data type: string. Allowed values:
readWrite
,readOnly
,writeOnly
.
Remarks
You can change the settings of multiple database users in a single packet. Add as many set-db-user operations to the packet as the number of different users you want to update.
<packet>
<database>
<set-db-user>
...
</set-db-user>
...
<set-db-user>
...
</set-db-user>
</database>
</packet>
Note: When creating request packets, put nodes and elements in the order they follow in the packet structure.
Response Packet Structure
The set-db-user node of the output XML packet is presented by the
type DatabaseSetDBUserOutputType (database_output.xsd
) and is
structured as follows:
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: resultType (
common.xsd
). - The status node is required. It specifies the execution status of the set-db-user operation. Data type: string. Allowed values: ok | error.
- The errcode node is optional. Is returns the error code if the set-db-user operation fails. Data type: integer.
- The errtext node is optional. It returns the error message if the set-db-user operation fails. Data type: string.
- The id node is optional. If the set-db-users operation succeeds, it specifies the ID of the updated database user. Data type: string.
Samples
This request packet sets a new password for the database user identified by ID 61, adds an ACL record, restricts access by IP address, and grants the user the Read Only role.
<packet>
<database>
<set-db-user>
<id>61</id>
<password>a1b2c3d</password>
<acl>
<host>127.0.0.1</host>
</acl>
<allow-access-from>
<ip-address>10.12.13.14</ip-address>
</allow-access-from>
<role>readOnly</role>
</set-db-user>
</database>
</packet>
Reponse:
<packet>
<database>
<set-db-user>
<result>
<status>ok</status>
<id>61</id>
</result>
</set-db-user>
</database>
</packet>