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.