MySQL – Fastest Way to Move Multiple Databases to a New Server

migrationMySQL

I have several small to medium sized mysql databases, say about 40 and I need to migrate them from one whm server with different cpanel accounts to another one with the accounts set up from the previous server and old versions of the databases I am moving already in place.

Could anyone recommend the quickest way of doing this, I was going to manually dump each one and import it across but it seems very time consuming, I would like to cut out my machine as the middle man if possible and automate were I can.

Best Answer

I do not know much about cPanel, but I know how to transfer a database very fast to another server - if you have access to ssh.

use mysqldump with the proper parameters and chain it with ssh. so the database is imported while the sorce database still exports. no temporary files are used (except mysql internally ;))

sourceserver# mysqldump --user=user1 --all-databases | ssh targethost 'mysql --user=user2'

if you authenticate to the source server with your private key and ssh-agent, you could use the -A option of ssh to connect. So you do not need to care about authorization on target side. But keep in mind:

         Agent forwarding should be enabled with caution.  Users with the
         ability to bypass file permissions on the remote host (for the
         agent's Unix-domain socket) can access the local agent through
         the forwarded connection.  An attacker cannot obtain key material
         from the agent, however they can perform operations on the keys
         that enable them to authenticate using the identities loaded into
         the agent.

(source: man 1 ssh)

hope this helps a bit

Related Topic