Sunday, 24 February 2013 17:25

Moving a database between domains in plesk

Written by 
1
Rate this item
(0 votes)

I have recently transferred a handful of websites from a server running on Plesk to my own running on cPanel. Unfortunately when I had finished I realised that on a few of the accounts the database was missing! When I logged back in to the old server I noticed that they databases had been made separately by the main admin using the server, but they weren’t linked to the actual domain needed. Rather than copy the databases and permission over separately it was much easier to move the database so it sat under the correct domain, and then transferred the Plesk account over again.

 

Log into the server using ssh then issue this command to get into the MySQL command line tool:

$ mysql -u admin -p -D psa

You will need to enter your Plesk admin password.

Next take a look at the current database list:

mysql> select * from data_bases;

+----+-------------------+-------+--------+--------------+-----------------+
| id | name              | type  | dom_id | db_server_id | default_user_id |
+----+-------------------+-------+--------+--------------+-----------------+
|  1 | consilience_db    | mysql |      1 |            1 |               1 |
|  2 | client1_db        | mysql |     18 |            1 |               2 |
| 29 | client2_db        | mysql |      6 |            1 |               4 |
+----+-------------------+-------+--------+--------------+-----------------+
3 rows in set (0.00 sec)

Each database will be listed with their name and “dom_id” (domain ID). Find the ID of the database you want to move, and find the dom_id of the domain you want to move it to (the dom_id will appear in the URLs used to manage the domain in the Plesk admin screens). Then update the dom_id, for example to set database ID 29 to be owned by domain 18:

mysql> update data_bases set dom_id = 18 where id = 29;

That’s it – the database will now appear under the new domain in Plesk.

This will only work on a single server.

Read 39021 times Last modified on Sunday, 24 February 2013 18:05

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.