Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL syntax error near gunzip when 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.

like image 620
Vikalp Jain Avatar asked Apr 20 '13 21:04

Vikalp Jain


1 Answers

While Kisoft´s answer is the correct one, I just wanted to point out that you don´t need the -c, it works just fine as it is. this command will unzip the database dump and import it into the database at the same time.

gunzip < output.sql.gz | mysql -u <username> -p<password> <database>
like image 161
Comocho00 Avatar answered Sep 27 '22 20:09

Comocho00