The database.exe utility serves to manage databases and database user accounts used by Plesk domains. The utility allows the following operations:

  • creating and removing databases
  • adding and removing database user accounts
  • editing database user credentials
  • adding or removing access control records for MySQL database users
  • adding firewall access rules for SQL Server database users

Location

%plesk_cli%

Usage

database.exe <command> [<database_name>] [
<option 1> <param> [<option 2> <param>] ... [<option N> <param>]
]

Example

The following command creates the MySQL database jdoe-gallery on the domain example.com.

plesk bin database.exe --create jdoe-gallery -domain example.com -type mysql

Commands

Command Parameter Description Example
--create or -c <database_name>

Creates a database with a specified name.

Requires -domain option.

To create the jdoe-gallery database on example.com:

plesk bin database.exe --create jdoe-gallery -domain example.com -type mysql

or

plesk bin database.exe -c jdoe-gallery -domain example.com -type mysql

--update or -u <database_name> Updates a database: adds, edits, removes a database user.

To update the jdoe-gallery database with the new user JohnDoe:

plesk bin database.exe --update jdoe-gallery -add_user JohnDoe -passwd sample

or

plesk bin database.exe -u jdoe-gallery -add_user JohDoe -passwd sample

--remove or -r <database_name> Deletes a specified database.

To remove the jdoe-gallery database from example.com:

plesk bin database.exe --remove jdoe-gallery -domain example.com

or

plesk bin database.exe -r jdoe-gallery -domain example.com

--register <database_name> Registers a database in Plesk and assigns it to a domain.

To register the database sampledb found on the local MySQL server in Plesk and assign it to the domain example.com:

plesk bin database.exe --register sampledb -domain example.com -server localhost:3306

--assign-to-subscription <database_name> Assigns the database to a subscription.

To assign the database jdoe-gallery to the subscription owning the domain example.com:

plesk bin database.exe --assign-to-subscription jdoe-gallery -domain example.com -server localhost:3306

--remove-dbs <ID,ID,...>

Deletes multiple databases specified with their ID from respective databases servers.

ID is the unique Plesk database ID.

To delete databases which Plesk ID are 14 and 56:

plesk bin database.exe --remove-dbs 14,56

--remove-dbus <ID,ID,...>

Deletes multiple database users.

Parameter ID is the unique Plesk database ID.

To delete database users whose Plesk ID are 22 and 34:

plesk bin database.exe --remove-dbus 22,34

--create-dbuser <login>

Creates a database user with the specified name. Requires -passwd, -server, -domain options. Also, -database or -any-database option can be specified.

We recommend that you use this command instead of --update <database> -add-user <user>.

To create the database user John with the password mypassword for the database mydb on the domain example.com:

plesk bin database.exe --create-dbuser John -passwd mypassword -domain example.com -server localhost:3306 -database mydb

--update-dbuser <login>

Updates a database user with the specified name.

Requires the -server option.

We recommend that you use this command instead of --update <database> -update-user <user>.

To update the password for the database user John:

plesk bin database.exe --update-dbuser John -passwd newpassword -server localhost:3306

--remove-dbuser <login>

Removes a database user with the specified name.

We recommend that you use this command instead of --update <database> -remove-user <user>.

To remove the universal database user John with the password mypassword on the domain example.com:

plesk bin database.exe --remove-dbuser John -server localhost:3306

--register-dbuser <login> Registers a database user in Plesk and assigns it to a database.

To register the database user dbuser found on the local MySQL server in Plesk, assign it to the database sampledb belonging to the domain example.com, grant the user the Read and Write permissions, and set the user’s password to dbpass:

plesk bin database.exe --register-dbuser dbuser -domain example.com -database sampledb -type mysql -user-role readWrite -passwd dbpass

--repair-mysql-dbusers  

Repairs MySQL user passwords. This operation might be necessary if you upgraded to Plesk 11.5 or later from earlier versions.

By default, the -serve r is localhost.

To repair MySQL user passwords for databases on the domain example.com:

plesk bin database.exe --repair-mysql-dbusers

--help or -h   Displays help on the use of the utility.

To view the help info on the use of this utility:

plesk bin database.exe --help

or

plesk bin database.exe -h

Options

Option Parameter Description Example
-domain <domain name>

Specifies a domain name.

Required with --create.

To create the MySQL database jdoe-gallery on example.com.

plesk bin database.exe --create jdoe-gallery -domain example.com -type mysql

-type mssql|mysql

Specifies a type of a database.

Either the -type or the -server option is required with --create.

To create the MySQL database jdoe-gallery on example.com.

plesk bin database.exe --create jdoe-gallery -domain example.com -type mysql

-passwd <password>

Specifies a database user password.

Required with -add_user.

Used with either the -add_user or -update_user option.

To set password of jdoe-gallery user with the login name JohnDoe to 123456:

plesk bin database.exe --update jdoe-gallery -update_user JohnDoe -passwd 123456

-add_user <login>

Creates a database user.

Requires -passwd option.

To create the jdoe-gallery database user with the login name JohnDoe:

plesk bin database.exe --update jdoe-gallery -add_user JohnDoe -passwd 12345

-update_user <login Changes a database user credentials (password and/or login).

To set password of jdoe-gallery user with the login name JohnDoe to 123456:

plesk bin database.exe --update jdoe-gallery -update_user JohnDoe -passwd 123456

-remove_user <login> Removes a database user with a specified name from the specified database.

To remove the JohnDoe user from jdoe-gallery database:

plesk bin database.exe --update jdoe-gallery -remove_user JohnDoe

-user_name <login>

Sets a login name for a database user.

Used with -update_user option only.

To rename jdoe-gallery database user from JohnDoe to John:

plesk bin database.exe --update jdoe-gallery -update_user JohnDoe -user_name John

-database <name> Sets the database to which a database user will have access. Is used with the --create-dbuser and --update-dbuser commands, but is not obligatory because you can create a user and not assign it to a database.

To create the database user John with the password mypassword for the database mydb on the domain example.com:

plesk bin database --create-dbuser John -passwd mypassword -domain example.com -server localhost:3306 -database mydb

-user-role readWrite|readOnly|writeOnly Sets the database user’s role. Is used with the --create-dbuser and the --update-dbuser commands.

To set the role of the JDoe user to “read only”:

plesk bin database.exe --update-dbuser JDoe -user-role readOnly

-any-database   Grants a database user access to all databases within the corresponding hosting account, thus making this user a universal database user. Is used with the --create-dbuser and --update-dbuser commands.

To create the database user John with the password mypassword and with access to all databases within the domain example.com:

plesk bin database.exe --create-dbuser John -passwd mypassword -domain example.com -server localhost:3306 -any-database

-allow-access-from <IP address 1, IP address 2, ...> Allows remote connections to the database from the specified IP addresses. The addresses are added to firewall rules. It works for database users of a local SQL Server.

To allow access to the SQL Server database jdoe-gallery from IP address 192.0.2.78:

plesk bin database.exe - -u jdoe-gallery -allow-access-from 192.0.2.78

-add-access <host>

Adds an access record for a database user: IP address or name of a host from which a database user can remotely access a MySQL database. The MySQL database can be local or remote.

This option adds a new record to the existing MySQL ACL (access control list). To replace the entire list with a new list, use the -set-acl option.

Host can be specified by either its host name or IP address. A subnet mask can be specified, too. MySQL wildcard characters (_ and %) are allowed; for more information, consult http://dev.mysql.com/doc/refman/5.0/en/connection-access.html).

To enable remote access to the database jdoe-gallery from the host with IP address 192.0.2.78 for the database user Jane:

plesk bin database.exe - -u jdoe-gallery -update_user Jane -passwd sample -add-access 192.0.2.78

-remove-access <host>

Removes an access record for a database user: IP address or name of a host from which a database user can remotely access the database.

This option removes a record from an existing MySQL ACL (access control list).

Host can be specified by either its host name or IP address. A subnet mask can be specified, too. MySQL wildcard characters (_ and %) are allowed; for more information, consult http://dev.mysql.com/doc/refman/5.0/en/connection-access.html).

To disable remote access to database jdoe-gallery from the host with IP address 192.0.2.78 for the database user Jane:

plesk bin database.exe - -u jdoe-gallery -update_user Jane -passwd sample -remove-access 192.0.2.78

-set-acl <host 1, host 2, ..., host n>

Sets up the MySQL access control list (ACL) for the specified database user, for example, on order to enable remote access to the database on behalf of this user. The MySQL database can be local or remote.

This option replaces an existing ACL with the specified one.

Host can be specified by either its host name or IP address. A subnet mask can be specified, too. MySQL wildcard characters (_ and %) are allowed; for more information, consult http://dev.mysql.com/doc/refman/5.0/en/connection-access.html).

To enable remote access to the MySQL database jdoe-gallery from remote hosts with IP address 192.0.2.78 and 192.0.2.79 for the database user with the name Jane:

plesk bin database.exe -u jdoe-gallery -update_user Jane -set-acl 192.0.2.78, 192.0.2.79

-set-privileges <name,name,...>

Adds one or more privileges to the specified database user on the specified database.

Used with the --add_user and the --update_user commands.

Available privileges are: Select, Insert, Update, Delete, Create, Drop, Alter, Index, Create Temporary Tables, Lock Tables, Create View, Show View.

Also sets global privileges for the specified database user on all the databases on the hosting account.

Available global privileges are: File, Create Routine, Alter Routine, Execute, Event, Trigger.

To add the Select privilege for the user JDoe on the database jdoe-gallery hosted on the local MySQL server:

plesk bin database.exe --update-dbuser JDoe -set-privileges Select -database jdoe-gallery -server localhost:3306

 -server host[:port]

Specifies the host name or IP address and port number for the machine on which a database server is hosted.

Used only with the --create command

To create database jdoe-gallery for the domain example.com on the database server accessible at 192.0.2.78:3838 and print the Plesk database ID:

plesk bin database.exe --create jdoe-gallery -domain example.com -server 192.0.2.78:3838 -print-id

-print-id  

Prints the created database or database user ID number.

Used only with the --create command or the -add_user option.

To create database jdoe-gallery for the domain example.com on the database server accessible at 192.0.2.78:3838 and print the Plesk database ID:

plesk bin database.exe --create jdoe-gallery -domain example.com -server 192.0.2.78:3838 -print-id

-default  

Makes the specified user the default user for the specified database.

Used with the --add_user and the --update_user commands.

To make the user JDoe the default user for the database jdoe-gallery hosted on the local MySQL server:

plesk bin database.exe --update-dbuser JDoe -default -database jdoe-gallery -server localhost:3306

-collation <collation name> Sets the collation for the specified database.

To set the collation for the database jdoe-gallery to utf8_general_ci:

plesk bin database.exe -u jdoe-gallery -collation utf8_general_ci

-charset <charset> Specifies a character set for a PostgreSQL database to be created.

To create database jdoe-gallery for the domain example.com on the PostgreSQL server available at 192.0.2.78:3838 and set the database’s charset to UTF-8:

plesk bin database.exe -c jdoe-gallery -domain example.com -charset UTF-8 -server 192.0.2.78:3838