Mysql – How to copy MySQL Database from Linux to Windows

linuxMySQLmysqldumpwindows

I would like to copy a MySQL database form Linux to Windows, from a little research I found this url http://www.cyberciti.biz/tips/howto-copy-mysql-database-remote-server.html where the author says we could copy MySQL Database using the following command in Linux

Linux to Linux

mysqldump -u username -p 'password' db-name | ssh user@remote.box.com mysql -u username -p 'password' db-name

Is there a command for copying MySQL database from Linux to Windows?

Best Answer

Linux -> Windows you have two obvious options.

  1. Setup a SSHD on your Windows machine and use the above command (mysql binary would need to be in your search path under Windows).

  2. Configure your root (or similar privileged account) to access your Windows MySQL host over network then do:

mysqldump -u username -p 'password' db-name | mysql -h windowsip -u username -p 'password' db-name

Unfortunately with #2, if you have complex indicies (or huge tables) you'll have issues with net_read_timeout on your Linux host. For most situations I would expect this to just work, though.