ghurty Posted February 21, 2011 Share Posted February 21, 2011 I am trying to move about 40 databases from one server to another. Is there an easy to use command that will allow me to do that? The two servers are on separate private networks, so I may not be able to copy them directly, so what I would want to do is create a backup, then manually move it and the restore it. I belive I need to exclude informatio_schema as well as the mysql databses. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/228443-easy-way-to-move-40-databases-from-one-server-to-another/ Share on other sites More sharing options...
darkfreaks Posted February 22, 2011 Share Posted February 22, 2011 Usually you run mysqldump to create a database copy and backups as follows: $ mysqldump -u user -p db-name > db-name.out Copy db-name.out file using sftp/ssh to remote MySQL server: $ scp db-name.out user@remote.box.com:/backup Restore database at remote server (login over ssh): $ mysql -u user -p db-name < db-name.out OR $ mysql -u user -p 'password' db-name < db-name.out Quote Link to comment https://forums.phpfreaks.com/topic/228443-easy-way-to-move-40-databases-from-one-server-to-another/#findComment-1177987 Share on other sites More sharing options...
ghurty Posted February 22, 2011 Author Share Posted February 22, 2011 In order to do that, I have to do this to each database individually. Is there a way to do multiple databases at once? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/228443-easy-way-to-move-40-databases-from-one-server-to-another/#findComment-1178027 Share on other sites More sharing options...
lastkarrde Posted February 22, 2011 Share Posted February 22, 2011 Write a shell script, put the above commands in a loop and iterate over the names of your databases. Quote Link to comment https://forums.phpfreaks.com/topic/228443-easy-way-to-move-40-databases-from-one-server-to-another/#findComment-1178028 Share on other sites More sharing options...
trq Posted February 22, 2011 Share Posted February 22, 2011 mysqldump has an --all-databases option or a --databases option that takes a space seperated list of database names. Does no one look at the manual's these days? Quote Link to comment https://forums.phpfreaks.com/topic/228443-easy-way-to-move-40-databases-from-one-server-to-another/#findComment-1178063 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.