Vikalp Jain Vikalp Jain - 7 months ago 34
SQL Question

Restoring a database using .sql.gz file

I am trying to restore a mysql db using a .sql.gz file. I am using mySql console to run a command because file size is too large for phpMyAdmin. Command I am using is

gunzip C:/Vik/Gya/Source/beed_2013-04-06.sql.gz | mysql -u root -p bd


where root is the user id. There is no password for root. bd is the database to which I am trying to import. mysql is running on my local machine (Windows 8). I have a wamp setup.

This is the error I am getting:


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
'gunzip
C:/Vikalp/Gyankosh/Source/beedictionary_2013-04-06.sql | mysql -u root
-p'
at line 1.


Any help will be greatly appreciated.

Thanks and regards,
Vikalp Jain

Answer

If you type gunzip and you get a SQL syntax error that complaints about gunzip, you are already logged into the mysql console. The mysql console is not a Unix shell!

Edit #1: I've just noticed you are using Windows. That makes me think that you haven't even installed gzip in your computer and you're just attempting to run a command you found somewhere.

My advice is that you get an archiver that can open .gz files (7-Zip will do). Then, you can use the source (\.) command:

mysql> \. C:/Vikalp/Gyankosh/Source/beedictionary_2013-04-06.sql

Note the prompt is mysql> and not C:\>.

Of course, you could also get a GUI client.

Edit #2: Alternatively, gzip is also available for Windows. Just install it and run your original command.

Comments