Mysql – Restore MySQL database dump on Windows machine using command line

MySQL

I have mysql installed on my machine, and I have an empty database my_database. I'd like to restore a database dump, originally from my shared server, into this empty database. The database dump is stored at C:/My Document Names Have Spaces/my_dump.sql

I've tried:

mysql -u USERNAME -p my_database < "C:/My Document Names Have Spaces/my_dump.sql";

… and many variants thereon (different quotes, different slashes), and I keep getting syntax errors.

What am I doing wrong?

Best Answer

Specify the database you are loading the mysqldump into iwth the -D option (nospace between -D and database bame)

mysql -u USERNAME -p -Dmy_database < 
"C:/My Document Names Have Spaces/my_dump.sql"; 

Or may you want to do this interactively.

Do the following:

1) Goto that directory in a DOS Window

C:> cd "C:\My Document Names Have Spaces"

2) Login to mysql client

C:\My Document Names Have Spaces> mysql -u USERNAME -p 

3) set yourself to the my_database

mysql> use my_database

3) load that file

mysql> source my_dump.sql

Watch the fireworks from there !!!

Give it a Try !!!