How to migrate local database between Plesk servers manually

Created:

2016-11-16 13:08:04 UTC

Modified:

2017-04-24 11:18:43 UTC

0

Was this article helpful?


Have more questions?

Submit a request

How to migrate local database between Plesk servers manually

Applicable to:

  • Plesk for Linux

Question

How to migrate local database between Plesk servers manually?

Answer

Local databases are databases that are created through Plesk on a local MySQL server. This is the default database server used by Plesk.

Using the instructions below, it is possible to migrate a local MySQL database between Plesk servers manually.

  1. On the source server, get information about the local databases on the created domain, example.com :

    source ~# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin psa
    mysql> select d.name as domain, db.name as db_name, dbu.login, a.password from domains d, data_bases db, db_users dbu, accounts a where db.dom_id=d.id and dbu.db_id=db.id and dbu.account_id=a.id and d.name=' example.com';
    +-------------+---------------+--------------+----------------+
    | domain      | db_name       | login        | password       |
    +-------------+---------------+--------------+----------------+
    | example.com | DATADASE_NAME | DB_USER_NAME | DB_USER_PASSWD |
    +-------------+---------------+--------------+----------------+
    1 row in set (0.01 sec)
  2. On the source server, back up the database. You may use the following command:

    source ~# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -uadmin DATADASE_NAME > DATADASE_NAME.dump

Move the dump to the destination server.

  1. On the destination server, create the database DATADASE_NAME on the domain example.com with Plesk CLI /usr/local/psa/bin/database . Assign the same username and password as on the source:
    destination ~# /usr/local/psa/bin/database --create DATADASE_NAME -domain DOMAIN.NAME -type mysql -passwd DB_USER_PASSWD  -passwd_type plain -add_user DB_USER_NAME -server localhost

Database creation through Plesk CLI utility /usr/local/psa/bin/database will update the Plesk database with the appropriate username and password . Run the utility with --help option to get a list of all available options. After creation, it is possible to log in to the database through DB WebAdmin in Plesk on the destination server: Home > Domains > example.com > Databases > DATADASE_NAME > DB WebAdmin

  1. On the destination server, restore the content of the database from the dump created on the source server:
    destination ~# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -uadmin DATADASE_NAME < DATADASE_NAME.dump ``
Have more questions? Submit a request
Please sign in to leave a comment.