MySQL database Latin1 to utf8

Source: Internet
Author: User

My previous database encoding is the default Latin1, but I want to convert it to utf8, Baidu, and Google for a long time. There are many methods, but many methods are either too troublesome or hard to understand.

 

After checking for half a day and testing for half a day, I finally got it done. Next I will write down the steps

Test environment: Window XP

MySQL version: 5.0

1. Use mysqldump to export the database Latin1 encoding to an SQL file.

 

C:/>D:

D:/>Cd d:/program files/MySQL Server 5.0/bin
D:/program files/MySQL Server 5.0/bin>Mysqldump-uroot-p -- quick -- compatible = mysql40 -- default-character-set = Latin1 -- extended-insert = false test> D:/test. SQL

 

Test is the name of the database you want to export data. D:/is the path. Set it to the desired path,Test.. SQL is a randomly named file with a random name. You only need a. SQL suffix.

The program will prompt you to enter the root user password (if there is a password), enter it, and the program will start exporting.

 

Important:-- Compatible = mysql40 -- default-character-set = Latin1After the -- compatible = mysql40 parameter is specified, you can specify the database encoding.

2. Step 2, create a new database through mysql-front, Database Name: Test, set collection character set to utf8-general-li
Convert exported test. SQL to UTF-8 encoding and you can use ultraedit (file -- convert -- ASCII to utf8 ). -- It seems that the default encoding of test. SQL exported in XP is ASCII, so conversion is required. You can test whether conversion is required or not.

 

3. Import the backed up SQL file to the new database.
D:/program files/MySQL Server 5.0/bin>Mysql-uroot-p -- default-character-set = utf8 test <D:/test. SQL

Complete...

 

Open mysql-front and log on with utf8 encoding to see if you can see the cute Chinese characters.

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.