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.
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:
(source: man 1 ssh)
hope this helps a bit
Probably a little too much as @krissi answer works very good, but just in case you have to do it more than once, you can use a script like this: