Articles in this section

How to register an existing database in Plesk

Plesk for Windows kb: how-to Plesk for Linux ABT: Group B FR:PPM-2853

Applicable to:

  • Plesk for Linux
  • Plesk for Windows

Question

A database exists in a database server, but is absent in Plesk at Domains > example.com > Databases.

How to register an existing database in Plesk?

Answer

Below are common examples of registering existing databases.

To see all available commands for registering existing databases, see:

 

Registering an existing MySQL database in Plesk for Linux

 

  1. Connect to a Plesk server via SSH.
  2. List all database servers registered in Plesk:

    # plesk db "SELECT host,port FROM DatabaseServers"

    An output will be like this:

    CONFIG_TEXT: +-------------+------+
    | host        | port |
    +-------------+------+
    | 203.0.113.2 | 3306 |
    | localhost   | 3306 |
    | localhost   | 5432 |
    +-------------+------+

  3. Register a database in Plesk and add it to the subscription database pool:

    # plesk bin database --register db_name -domain example.com -server 203.0.113.2:3306

    where:

    • db_name - database name
    • example.com - name of the subscription to which the database is going to be attached
    • 203.0.113.2 - name of the registered database server from step 2
    • 3306 - MySQL port number
  4. Register an existing database user with the command:

    # plesk bin database --register-dbuser db_user -domain example.com -database db_name -user-role readWrite -passwd '<password>' -server 203.0.113.2:3306

    where:

    • db_user - database username
    • example.com - subscription name specified on step 3
    • db_name - database name specified on step 3
    • <password> - password of the database user
    • 203.0.113.2 - name of a registered database server from step 2
    • 3306 - MySQL port number

 

Registering an existing PostgreSQL database in Plesk for Linux

 

  1. Connect to a Plesk server via SSH.
  2. List all database servers registered in Plesk:

    # plesk db "SELECT host,port FROM DatabaseServers"

    An output will be like this:

    CONFIG_TEXT: +-------------+------+
    | host        | port |
    +-------------+------+
    | localhost   | 3306 |
    | localhost   | 5432 |
    +-------------+------+

  3. Register a database in Plesk and add it to the subscription database pool:

    # plesk bin database --register db_name -domain example.com -server localhost:5432

    where:

    • db_name - database name
    • example.com - name of the subscription to which the database is going to be attached
    • localhost - name of the registered database server from step 2
    • 5432 - PostgreSQL port number
  4. Register an existing database user with the command:

    # plesk bin database --register-dbuser db_user -domain example.com -database db_name -user-role readWrite -passwd "<password>" -server localhost:5432

    where:

    • db_user - database username
    • example.com - subscription name specified on step 3
    • db_name - database name specified on step 3
    • <password> - password of the database user
    • localhost - name of a registered database server from step 2
    • 5432 - PostgreSQL port number

 

Registering an existing MySQL/MSSQL database in Plesk for Windows

 

  1. Make sure that a database server is registered in Plesk at Tools & Settings > Database Servers.
  2. Connect to a Plesk server via RDP and start a command prompt as an Administrator.
  3. List all database servers registered in Plesk:

    C:\> plesk db "SELECT host,port FROM DatabaseServers"

    An output will be like this:

    MYSQL_WIN: +-----------------------------+------+-------+
    | host                        | port | type  |
    +-----------------------------+------+-------+
    | .\MSSQLSERVER2017           | 0    | mssql |
    | 203.0.113.2                 | 3306 | mysql |
    | 203.0.113.2\MSSQLSERVER2016 |      | mssql |
    | localhost                   | 3306 | mysql |
    +-----------------------------+------+-------+

  4. Register a database in Plesk and add it to the subscription database pool:

    C:\> plesk bin database.exe --register db_name -domain example.com -server 203.0.113.2 -type mysql

    where:

    • db_name - database name
    • example.com - name of the subscription to which the database is going to be attached
    • 203.0.113.2 - name of the registered database server from step 3
    • mysql - database server's type. In case MSSQL is used, replace the command with mssql
  5. Register a database user in Plesk and assign it to the database:

    C:\> plesk bin database.exe --register-dbuser db_user -domain example.com -database db_name -user-role readWrite -passwd "<password>" -server 203.0.113.2

    where:

    • db_user - database username
    • example.com - subscription name specified on step 4
    • db_name - database name specified on step 4
    • <password> - password of the database user
    • 203.0.113.2 - name of the registered database server from step 3

 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.