SQL syntax error near gunzip when restoring a database using .sql.gz file

Vikalp Jain picture Vikalp Jain · Apr 20, 2013 · Viewed 52.1k times · Source

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.

Answer

kisoft picture kisoft · Jul 29, 2013

You need -c option (output to stdout)

gunzip -c xxx.sql.gz |mysql -u root -p