I have downloaded my .sql file of my database server. It is in the D: drive of my Windows machine.

I want to restore the back up in my this machine. I used:

mysql database -u root < backupfile.sql

Where database is my new database name in this machine. My confusion is that my backupfile.sql is in the D: drive and thus I guess there is error.

ERROR 1064 <42000>:You have an error in your SQL syntax;Check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql database -u root < backupfile.sql' at line 1.
  • 2 questions, 1. what is the exactly path to backupfile.sql 2. does the backupfile.sq ends with -- Dump completed on xxxx-xx-xx xx:xx:xx ? Apr 22, 2013 at 8:46
  • 2
    You're supposed to run that command directly from the command prompt (cmd.exe), not inside the mysql prompt (in addition to specifying the full path as Abdul indicates).
    – Mat
    Apr 22, 2013 at 9:46
  • D:\backup\backup.sql is my exact path.Actually I have been using MySQL command line client 5.6 and not using from cmd.exe.I get error while running from cmd.exe.
    – kaji
    Apr 22, 2013 at 10:26

2 Answers 2


You should login to mysql like this

C:\> mysql -uroot -p <hit enter>
Enter password:

Next, select the database you want to load the data into

mysql> USE mynewdb

Then, run the script

mysql> source D:\backup\backup.sql

Give it a Try !!!

  • Yes sir I managed it as you have said and it works.I have my mysql.exe in the path C:\Program Files (x86)\MySQL\MySQL Workbench CE 5.2.47.So,first i add this path from control panel. Now I want to chance the max_allowed_packet=32M in the my.ini file.But I could not find .ini file.Looking for possible solutions.And thanks again for your answer.
    – kaji
    Apr 23, 2013 at 4:56

You should pass full path of .sql file like where it resides ex : "D:\file_name"

Try this one

 mysql -u YourUser -pYourPassword DBName < D:\backupfile.sql
  • I have done this as well.What I should have mentioned earlier is that I am using MySQL 5.6 command line client.
    – kaji
    Apr 22, 2013 at 10:19
  • Runing in cmd.exe too has error.Will you help me to run the mysql through cmd.exe
    – kaji
    Apr 22, 2013 at 10:21
  • MySQL Version doesn't have any effect on this.Can you please write exact steps what you are doing or paste the screen shot of your steps. Apr 22, 2013 at 10:22
  • From your error message.It looks like you are able to connect to MySQL,It means your steps are Ok it seems that your backup file has syntax errors.Can you look at line 1 to 10 of your backup file and also can you paste that here. Apr 22, 2013 at 10:26
  • sir my backup.sql file is 19GB in size. so i tried to open it with notepad, wordpad .But none of them was able to read it.Can you suggest me any possible reader for this.
    – kaji
    Apr 22, 2013 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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