MySQL database is converted from Latin1 to utf8

Source: Internet
Author: User

You need to convert the MySQL database from Latin1 encoding to utf8 encoding. Some methods searched online are useless.

I found a feasible method multiple times:

0. Download tool navicat for MySQL

1. Export the table structure of the database mysqldump-uuser-p-D dB> dB. SQL

2. Edit dB. SQL and replace Latin1 with utf8.

3. Create a new database newdb and run dB. SQL to create a table.

4. Use navicat for MySQL to connect to the database. Right-click the database table to be exported and select the export wizard.

4. 1. Select the XML file (*. XML) and click Next;

1252. Select All Tables, select the export path for each table in the export to column, click Advanced, and select (ANSI-Latin I );

. Continue to the next step until the end and click Start.

5. Use ue or notepad ++ to open the exported XML file and convert it to UTF-8 without BOM encoding format.

6. Open the import wizard for each table

6. 1. Select the XML file (*. XML) and click Next;

. Select the XML file to be imported and click Next;

. Select the label that indicates a table row as record;

. Continue to the next step until the end and click Start.

The entire conversion process is completed, so the table data is converted normally, including special symbols and single quotes.

Note: I have a table in the format of utf8. First export it with utf8 (default utf8 in step 1). No matter how it is converted, It is garbled.

I noticed later that although the table is encoded as utf8, Latin1 is used by default when storing data in web programs.

Therefore, it is exported as Latin1 and converted successfully.

Note: In fact, webpage Code cannot be converted. <A> </a> is transcoded by XML...

Solution: export the SQL file and execute the SQL file.

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.