使用mysqldump命令导出数据:
D:Program FilesMySQLMySQL Server 5.6in>mysqldump -hlocalhost -uroot -proot sinaweibo >D:devmysql_bkpsinaweibo.sql
将数据导入回数据库:
D:Program FilesMySQLMySQL Server 5.6in>mysql -hlocalhost -uroot -proot sinaweibo2 < D:devmysql_bkpsinaweibo.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 ''.
原因:导入数据时的默认编码(utf8)与导出文件的默认编码(utf8mb4)不一致。
解决办法:
D:Program FilesMySQLMySQL Server 5.6in>mysql -hlocalhost -uroot -proot --default-character-set=utf8mb4 sinaweibo2 < D:devmysql_bkpsinaweibo.sql