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?

link|improve this question
1  
Post an example of the syntax errors you're getting. – ErikA Feb 15 '11 at 21:09
Error message reads: Error 1604 (42000): You have an error in your SQL syntax... – Summer Feb 15 '11 at 21:11
I am running this from a mysql> command prompt. – Summer Feb 15 '11 at 21:12
feedback

2 Answers

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 !!!

link|improve this answer
Thanks for the help. Unfortunately, I was unable to go to the directory in a DOS window (stayed stubbornly stuck on H: drive) and DOS window also would not load msql ('mysql is not recognized as an internal or external command') Going to mysql and saying use my_database then source my_dump has potential, the error message changes to Error 22 Failed to Open File – Summer Feb 15 '11 at 21:29
feedback

It worked:

mysql> use my_database
mysql> source C:\My Document Names Have Spaces\\My Second Directory Names Do Too\\my_dump.sql
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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