I am fairly new to mysql...be gentle. I am trying to move mysql db from linux box to windows box where I do all the development.

Can someone tell, or reference me, how to do it step by steps?



Easiest thing to do would be to do a mysqldump on your linux box, and then import said dump into your local windows database.

First, the mysqldump (docs: http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html)

mysqldump -u [username] -p [any other options desired] [database name] > dump.sql

The above creates a file called "dump.sql" in the directory you ran that in. Next grab that dump.sql file from your linux box and bring it over to your windows box. Now, you can either use a GUI to import the dump (like navicat or sqlyog, or even phpmyadmin if you happen to have that handy), but the way you normally do this from the command line (on linux, you may have to make an adjustment on windows) is:

mysql -u [username] -p < dump.sql

And that's it! The above line pipes the dump.sql file into mysql. The dump file is nothing more than a bunch of SQL statements, which is why the above works. Sorry for not being able to provide windows-specific command line instructions, it's been a while since I've worked with windows :) Hope that helps.

  • so the dump file will contain all the populated tables? – ultraman Jul 27 '09 at 17:30
  • By default, yes... make sure you take a look over all the flags in the docs tho, there are ways to turn this off / on (or specify only certain tables be dumped, etc.) Easiest way to confirm everything worked right in the dump is to simply open the dump.sql file and see what it dropped in there. – Ian Selby Jul 27 '09 at 17:36
  • 1
    As Ian implied, the dump is just a text file full of sql statements that you can view with pretty much any text editor. – Kyle Brandt Jul 27 '09 at 18:05

You can try copying MySQL database files. This should work: they're often binary compatible. On Linux, they're located in /var/lib/mysql

  • 1
    Yeah, but make sure you shut down the MySQL server first before you start moving those around :) – Ian Selby Jul 27 '09 at 16:30
  • 1
    Also, the data directory isn't always /var/lib/mysql on linux... depends a lot on your distro and / or how it was installed. – Ian Selby Jul 27 '09 at 16:31
  • Don't you run into a problem if Linux is running on a big endian machine like a Sparc server? – Jack M. Jul 27 '09 at 16:46
  • Heh, I know of the endians, that's why i wrote "often compatible" ;) – kolypto Jul 27 '09 at 17:09
  • ugh, I am copying over to windows box... – ultraman Jul 27 '09 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.