使用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 ' 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
