MySQL database conversion from GBK to UTF-8 simplest solution (also for other encoding conversions)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.