Recently, I used mysqldump in linux to export data. When I import data in windows, Chinese characters may be garbled and the following errors may occur: UnknownMySQLserverhost and Cantconnecttotheserver. To solve the problem of garbled data during mysql import and export, the encoding for unified import and export is used. In linux, the default encoding is utf8, while
Recently, I used mysqldump in linux to export data. When I import data in windows, Chinese characters may be garbled, which may lead: unknown MySQL server host and Can't connect to the server error. To solve the problem of garbled data during mysql import and export, the encoding for unified import and export is used. In linux, the default encoding is utf8, while
Recently, I used mysqldump in linux to export data. When I import data in windows, Chinese characters are garbled, and then the following occurs: unknown MySQL server host and Can't connect to the server error.
To solve the problem of garbled data during mysql import and export, the encoding for uniform import and export is used. The default encoding for linux is utf8 and for windows is gbk, so the above garbled code problem occurs.
Solve the Problem of garbled data during mysql Import and Export
The first thing to do is to determine the encoding format of the exported data. When using mysqldump, add -- default-character-set = utf8, for example, the following code:
Mysqldump-uroot-p -- default-character-set = utf8 dbname tablename> bak. SQL
When importing data, use -- default-character-set = utf8:
Mysql-uroot-p -- default-character-set = utf8 dbname <bak. SQL
In this way, the unified encoding solves the garbled characters in mysql data migration.