The database utility is used to manage databases and database users in Plesk through CLI. By using this utility, you can perform the following tasks:
Syntax
database <command> [<database name>] [
<option_1> [<param>]
[<option_2> [<param>]]
…[<option_N> [<param>]]
]
Example
The following command line creates database DataStoreDB on a database server accessible at the IP address and port number192.168.67.78:3838 and prints the created database's Plesk ID number:
# ./database --create DataStoreDB -domain example.com -server 192.168.67.78:3838 -print-id
Commands
Command |
Parameter |
Description |
Example |
|---|---|---|---|
|
|
Creates a database on a database server. Requires concomitant use of the |
To create database DataStoreDB on a the local MySQL server for domain example.com: # ./database --create DataStoreDB -domain example.com -type mysql or # ./database -c DataStoreDB -domain example.com -type mysql |
|
|
Updates database settings. Adds, edits, or removes a database user. |
To add user db_user to database DataStoreDB: # ./database --update DataStoreDB -add_user db_user or # ./database –u DataStoreDB -add_user db_user |
|
|
Deletes a database. |
To delete database DataStoreDB from the database server: # ./database --remove DataStoreDB or # ./database -r DataStoreDB |
|
<id#,id#,...>
|
Deletes multiple databases from their respective databases servers. |
To delete databases with with Plesk ID# 14 and ID# 56: # ./database --remove-dbs 14,56 |
|
<id#,id#,...>
|
Deletes multiple database users. |
To delete database users with Plesk ID# 22 and ID# 34: # ./database --remove-dbus 22,34 |
|
|
Displays help on the use of the utility. |
To see the help info on the use of this utility: # ./database -–help or # ./database –h |
Options
Option |
Parameter |
Description |
Example |
|
|---|---|---|---|---|
|
|
Specifies a domain name. Used with the |
To create database DataStoreDB on domain example.com on the local MySQL server: # ./database -c DataStoreDB -domain example.com -type mysql |
|
|
|
Specifies the type of the database. Used only with the |
||
|
|
Sets the database user password for accessing the database. Used in conjunction with the For additional comments, see the Note below the table. |
To set the password to dbuserpass for user db_user to access database DataStoreDB: # ./database -u DataStoreDB -update_user db_user -passwd dbuserpass |
|
|
|
Specifies the type of a database user password - Set to Used in conjunction with the For additional comments, see the Note below the table. |
To set the type of the client's password to encrypted for the database user with login name db_user: # ./database -u DataStoreDB -update_user db_user -passwd_type dbuserpass |
|
|
|
Adds a database user to the database. Requires concomitant use of the |
To add the user with login name db_user to database DataStoreDB: # ./database -u DataStoreDB -add_user db_user -passwd userpass |
|
|
|
Updates database user login data. |
To set the password to dbuserpass for user db_user to access database DataStoreDB: # ./database -u DataStoreDB -update_user db_user -passwd dbuserpass |
|
|
|
Removes a database user from the database. |
To add the user with login name db_user to database DataStoreDB: # ./database -u DataStoreDB -remove_user db_user |
|
|
|
Sets the login name for the DB user. Used with the |
To change the login name for the database user from db_user to db_newuser: # ./database -u DataStoreDB -update_user db_user -user_name db_newuser |
|
|
|
Adds an access record for a database user: IP address or name of a host from which a database user can remotely access the database. Host machine may be specified by either its host name or IP address. A subnet mask can be specified, too. MySQL wildcard characters ( |
To enable remote access to database DataStoreDB from a host with IP address 192.168.67.78 for the database user db_user: # ./database -u DataStoreDB -update_user db_user -passwd dbuserpass -add-access 192.168.67.78 |
|
|
|
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. Host machine may be specified by either its host name or IP address. A subnet mask can be specified, too. MySQL wildcard characters ( |
To disable remote access to database DataStoreDB from a host with IP address 192.168.67.78 for the database user db_user: # ./database -u DataStoreDB -update_user db_user -passwd dbuserpass -remove-access 192.168.67.78 |
|
|
|
Specifies the host name or IP address and port number for the machine on which a database server is hosted. Used only with the |
To create database DataStoreDB on a database server accessible at 192.168.67.78:3838 and print the database's Plesk ID number: # ./database --create DataStoreDB -domain example.com -server 192.168.67.78:3838 -print-id |
|
|
|
Prints the created database or database user ID number. Used only with the |
||
|
|
Sets a character set for a PostgreSQL database to be created.
|
To create database DataStoreDB on domain example.com on the PostgreSQL server available at 192.168.67.78:3838 and set the database's charset to UTF-8: # ./database -c DataStoreDB -domain example.com -charset UTF-8 -server 192.168.67.78:3838 |
|
Note: Use of this option is not recommended. Passing passwords through CLI as parameters of the -passwd option may potentially compromise the system's security as command line can be observed by other users of the system. It is more secure to pass passwords through the environment variables. You can transfer non-encrypted passwords by using environment variable PSA_PASSWORD while using single quotes to specify the empty values in the command line for the argument of the -passwd - -passwd_type options.
Similarly, you can transfer encrypted passwords through the environment variable PSA_CRYPTED_PASSWORD while using single quotes to specify the empty values in the command line for the argument of the -passwd and -passwd_type options.