1, using mysqldump export table structure, such as:
mysqldump-d-u root-p database name >/root/struct.sql
2. Use mysqldump to export data in a specific encoding (where UTF8 is the desired encoding and can be modified as needed), such as:
Mysqldump--default-character-set=utf8-t-u root-p database name >/root/data.sql
3. Open the table structure dump (/ROOT/STRUCT.SQL) and replace all the encodings in the create table with the required encoding;
4. Enter the MySQL console and execute:
Source/root/struct.sql
Source/root/data.sql
can be completed.
When exporting a table, adding--skip-lock-tables can resolve if a 1044 error occurs:
mysqldump-d-u root-p database name--skip-lock-tables >/root/struct.sql
Mysqldump--default-character-set=utf8-t-u root-p database name--skip-lock-tables >/root/data.sql
MySQL database conversion from GBK to UTF-8 simplest solution (also for other encoding conversions)