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
我正在尝试使用.sql恢复mysql db。gz文件。我使用mySql控制台运行命令,因为文件大小对phpMyAdmin来说太大了。我正在使用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.
root是用户id, root没有密码。bd是我要导入的数据库。mysql在我的本地机器(Windows 8)上运行,我有wamp安装。
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.错误1064 (42000):SQL语法中有错误;检查与MySQL服务器版本相对应的手册,找到在“gunzip C:/Vikalp/Gyankosh/Source/beedictionary_2013-04-06附近使用的正确语法。sql | mysql -u root -p'在第1行。
Any help will be greatly appreciated.
如有任何帮助,我们将不胜感激。
Thanks and regards, Vikalp Jain
谢谢你,Vikalp Jain。
6 个解决方案
#1
4
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 general purpose shell!
如果您输入gunzip并得到一个SQL语法错误,抱怨gunzip,您已经登录到mysql控制台。mysql控制台不是通用shell!
You are using Windows and I suspect you haven't installed gzip in your computer (it isn't a builtin utility). It's a classical Unix tool but you can find binaries for Windows. Install it and run your original command with a couple of tweaks:
您正在使用Windows,我怀疑您的计算机中没有安装gzip(它不是内置实用程序)。这是一个经典的Unix工具,但是你可以找到Windows的二进制文件。安装它并运行您的原始命令与一些调整:
-
Make sure you're in Windows prompt (
C:\>
)确保你在Windows提示符(C:\>)
-
Redirect gunzip result to stdout rather than a file:
将gunzip结果重定向到stdout而不是文件:
gunzip --stdout C:/Vik/Gya/Source/beed_2013-04-06.sql.gz | mysql -u root -p bd
Alternatively, you can run the dump from within MySQL promt (mysql>
) if you uncompress it first (you don't need specifically command-line gzip, most GUI archivers such as 7-Zip support this format):
或者,如果您先解压,您可以在MySQL promt (MySQL >)中运行转储文件(您不需要特定的命令行gzip,大多数GUI归档文件(如7-Zip)都支持这种格式):
mysql> \. C:/Vikalp/Gyankosh/Source/beedictionary_2013-04-06.sql
#2
68
You need -c option (output to stdout)
您需要-c选项(输出到stdout)
gunzip -c xxx.sql.gz |mysql -u root -p
#3
22
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.
虽然Kisoft´s答案是正确的,我只是想指出,´你不需要- c,它工作得很好。此命令将解压缩数据库转储并同时将其导入数据库。
gunzip < output.sql.gz | mysql -u <username> -p<password> <database>
#4
1
Your answer is already here
你的答案已经在这里了。
phpMyAdmin: Can't import huge database file, any suggestions?
phpMyAdmin:不能导入大型数据库文件,有什么建议吗?
Under php.ini file, normally located in c:\xampp\php or wampp whatever you called
在php中。ini文件,通常位于c:\xampp\php或wampp中
post_max_size=128M
upload_max_filesize=128M
Changing value there will get you what you want.Good luck Dont forget to restart , apache and mysql .
不断变化的价值会让你得到你想要的。幸运的是,不要忘记重启apache和mysql。
#5
1
you do not need to gunzip just: zcat myfile.gz | mysql -uuser -ppassword mydatabase it is faster this way
您不需要gunzip只是:zcat myfile。mysql -uuser -ppassword mydatabase这样更快
#6
0
Try this following steps to restore db using .gz files:
尝试以下步骤,使用.gz文件恢复db:
1. Run command : gunzip C:/Vik/Gya/Source/beed_2013-04-06.sql.gz
This will uncompress the .gz file and will just store beed_2013-04-06.sql in the same location.
这将解压.gz文件,只存储beed_2013-04-06。sql位于同一位置。
2. Type the following command to import sql data file:
mysql -u username -p bd < C:/Vik/Gya/Source/beed_2013-04-06.sql
#1
4
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 general purpose shell!
如果您输入gunzip并得到一个SQL语法错误,抱怨gunzip,您已经登录到mysql控制台。mysql控制台不是通用shell!
You are using Windows and I suspect you haven't installed gzip in your computer (it isn't a builtin utility). It's a classical Unix tool but you can find binaries for Windows. Install it and run your original command with a couple of tweaks:
您正在使用Windows,我怀疑您的计算机中没有安装gzip(它不是内置实用程序)。这是一个经典的Unix工具,但是你可以找到Windows的二进制文件。安装它并运行您的原始命令与一些调整:
-
Make sure you're in Windows prompt (
C:\>
)确保你在Windows提示符(C:\>)
-
Redirect gunzip result to stdout rather than a file:
将gunzip结果重定向到stdout而不是文件:
gunzip --stdout C:/Vik/Gya/Source/beed_2013-04-06.sql.gz | mysql -u root -p bd
Alternatively, you can run the dump from within MySQL promt (mysql>
) if you uncompress it first (you don't need specifically command-line gzip, most GUI archivers such as 7-Zip support this format):
或者,如果您先解压,您可以在MySQL promt (MySQL >)中运行转储文件(您不需要特定的命令行gzip,大多数GUI归档文件(如7-Zip)都支持这种格式):
mysql> \. C:/Vikalp/Gyankosh/Source/beedictionary_2013-04-06.sql
#2
68
You need -c option (output to stdout)
您需要-c选项(输出到stdout)
gunzip -c xxx.sql.gz |mysql -u root -p
#3
22
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.
虽然Kisoft´s答案是正确的,我只是想指出,´你不需要- c,它工作得很好。此命令将解压缩数据库转储并同时将其导入数据库。
gunzip < output.sql.gz | mysql -u <username> -p<password> <database>
#4
1
Your answer is already here
你的答案已经在这里了。
phpMyAdmin: Can't import huge database file, any suggestions?
phpMyAdmin:不能导入大型数据库文件,有什么建议吗?
Under php.ini file, normally located in c:\xampp\php or wampp whatever you called
在php中。ini文件,通常位于c:\xampp\php或wampp中
post_max_size=128M
upload_max_filesize=128M
Changing value there will get you what you want.Good luck Dont forget to restart , apache and mysql .
不断变化的价值会让你得到你想要的。幸运的是,不要忘记重启apache和mysql。
#5
1
you do not need to gunzip just: zcat myfile.gz | mysql -uuser -ppassword mydatabase it is faster this way
您不需要gunzip只是:zcat myfile。mysql -uuser -ppassword mydatabase这样更快
#6
0
Try this following steps to restore db using .gz files:
尝试以下步骤,使用.gz文件恢复db:
1. Run command : gunzip C:/Vik/Gya/Source/beed_2013-04-06.sql.gz
This will uncompress the .gz file and will just store beed_2013-04-06.sql in the same location.
这将解压.gz文件,只存储beed_2013-04-06。sql位于同一位置。
2. Type the following command to import sql data file:
mysql -u username -p bd < C:/Vik/Gya/Source/beed_2013-04-06.sql