Copying a mysql database generates “ERROR: unknown command” when importing

百般思念 提交于 2019-12-23 04:15:08

问题


I'm on a japanese system using xampp. This is the line I use to dump my database.

c:\xampp\mysql\bin>mysqldump.exe -uroot wp_newsja > dump.sql

Then I create a database on another server.

c:\xampp\mysql\bin>mysqladmin -uroot create db

But when I try to execute the sql...

c:\xampp\mysql\bin>mysql -uroot db < dump.sql

... I get the following error.

ERROR at line 145: Unknown command '¥''.

On a japanese computer windows path slashes / are represented with "¥". Which leads me to believe this is an utf8 issue. Maybe there is a way I can mysqldump with some utf8 flag? Thanks for any assistance! The exported sql is here: http://goo.gl/7MPVG - Error at line 145:

edit: Problem solved:

mysql --default-character-set=utf8 db < dump.sql

Sorry if I wasted anyone's time.


回答1:


mysql --default-character-set=utf8 db < dump.sql



回答2:


You can add this argument --default-character-set=utf8 in the command:

mysql -u USERNAME -p my_database --default-character-set=utf8 < "C:/My Document Names Have Spaces/my_dump.sql"

I've finally found this solution and it works fine with my new installed WampServer 2.5. I've also tried to add the default character setting in my.ini, but it's useless. Until I've tried the above argument added in my DOS batch file.

My batch file execute the command, like this way: 7zip x -so %1.%2.7z|%mysql% -uxxxx -pyyyyy %2 --default-character-set=utf8

For example, the 7zip filename is 20141231.google.7z, which contains "google.sql", and the database name is google

My backup process on Linux system was a 7zip compressed. In Winodws, I used an automatic batch file to restore the same contents, so that I can share the same database in my biz trip and work offline from the server.

Hope this method is helpful to you.



来源:https://stackoverflow.com/questions/12000697/copying-a-mysql-database-generates-error-unknown-command-when-importing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!