MySQL数据库导入错误:ERROR 1064 (42000) 和 ERROR at line xx: Unknown command '\Z'.

时间:2024-03-06 12:52:31

使用mysqldump命令导出数据:

D:\Program Files\MySQL\MySQL Server 5.6\bin>mysqldump -hlocalhost -uroot -proot sinaweibo >D:\dev\mysql_bkp\sinaweibo.sql

将数据导入回数据库:

D:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -hlocalhost -uroot -proot sinaweibo2 < D:\dev\mysql_bkp\sinaweibo.sql

报错:

ERROR 1064 (42000) at line 93: 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 \'\'13831064567&nbsp\' at line 1

ERROR at line 53: Unknown command \'\Z\'.

原因:导入数据时的默认编码(utf8)与导出文件的默认编码(utf8mb4)不一致。

解决办法:

D:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -hlocalhost -uroot -proot --default-character-set=utf8mb4 sinaweibo2 < D:\dev\mysql_bkp\sinaweibo.sql