开发者

Mysql ERROR at line 1153: Unknown command '\'

I am trying to import a mysqldump file via the command line, but continue to get an error. I dumped the file from my other server using:

mysqldump -u XXX -p database_name > database.sql

Then I try to import the file with:

mysql -u XXX -p database_name < database.sql

It loads a small portion and then gets stuck. 开发者_如何学PythonThe error I receive is:

ERROR at line 1153: Unknown command '\''.

I checked that line in the file with:

awk '{ if (NR==1153) print $0 }' database.sql >> line1153.sql

and it happens to be over 1MB in size, just for that line.

Any ideas what might be going on here?


You have binary blobs in your DB, try adding --hex-blob to your mysqldump statement.


You know what's going on - you have an extra single quote in your SQL!O

If you have 'awk', you probably have 'vi', which will open your line1153.sql file with ease and allow you to find the value in your database that is causing the problem.

Or... The line is probably large because it contains multiple rows. You could also use the --skip-extended-insert option to mysqldump so that each row got a separate insert statement.

Good luck.


I had the same problem because I had Chinese characters in my datasbase. Below is what I found from some Chinese forum and it worked for me.

mysql -u[USERNAME] -p[PASSWORD] --default-character-set=latin1
[DATABASE_NAME] < [BACKUP_SQL_FILE.sql]


I think you need to use path/to/file.sql instead of path\to\file.sql

Also, database < path/to/file.sql didn't work for me for some reason - I had to use use database; and source path/to/file.sql;.


If all else fails, use MySQLWorkbench to do the import. This solved the same problem for me.


I recently had a similar problem where I had done an sql dump on a Windows machine and tried to install it on a Linux machine. I had a fairly large SQL file and my error was happening at line 3455360. I used the following command to copy all text up to the point where I was getting an error:

sed -n '1, 3455359p' < sourcefile.sql > destinationfile.sql

This copied all the good code into a destination file. I looked at the last few lines of the destination file and saw that it was a complete SQL command (The last line ended with a ';') so I imported the good code and didn't get any errors.

I then looked at the rest of the file which was about 20 lines. It turns out that the export might not have completed b/c I saw the following php code at the end of the code:

Array
(
    [type] => 1
    [message] => Maximum execution time of 300 seconds exceeded
    [file] => C:\xampp\htdocs\openemr\phpmyadmin\libraries\Util.class.php
    [line] => 296
)

I removed the offending php code and imported the rest of the database.


I had special character in table names , like _\ and it give error when try to import that tables. i fixed it by changing \ to \\ in dumped sql. my table names where like rate_\ and i used this command to repair dump :

sed 's._\\._\\\\.g' dump.sql > dump2.sql

i didn't replace all backslashes , because i was not sure if there is some backslash somewhere in database that should not be replaces.

special characters in table name will be converted to @ at sign in file name. read http://dev.mysql.com/doc/refman/5.5/en/identifier-mapping.html


I have same error as,

 Unknown command '\▒'.

when I ran this

 mysql -u root -p trainee < /xx/yy.gz

So I'd followed these answers. But I did not got the restored db trainee. Then found that yy.gz is zip file. So I restoring after unzip the file as:

 mysql -u root -p trainee < /xx/yy.sql
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜