MySQL 4 database, if you want to migrate to MySQL 4.1, there will be Chinese Encoding Problems, relatedArticleIntroduction too
A little more, a lot of Google, the key is that MySQL 4.1 began to support multi-encoding. Today, I tried migration and insertion and reading and found some rules and problems, which are summarized as follows:
My machine is a Win2000 Server with MySQL 4, MySQL 4.1, and MySQL 5 installed. It uses phpMyAdmin 2.70 pl2.
First, I used phpMyAdmin to save a table in MySQL 4 as an ABC. SQL file.
Then, I will recover to MySQL 5 and use phpMyAdmin to input http: // localhost/phpmyadmin5/index. php (on the machine
Three phpMyAdmin instances are configured in the same version, but they connect to MySQL 4, MySQL 4.1, and MySQL 5 respectively.
Function, select gb2312 (this step is very important !), Then, the data table is imported,
Observe that at this time, each column of the data table is sorted by gb2312_chinese_ci, And the homepage set by phpMyAdmin
MySQL Character Set combination is uft-8, connection proofread is also uft-8, at the same time, in my. ini, Set
[Mysqld]
Character_set_server = utf8
[MySQL]
Default-character-set = utf8
At this time, we can see that the database is viewed with phpMyAdmin, and there is no Chinese garbled problem.
Next, we will go to PhPProgramNormal reading and adding operations to the database like previously written crud programs. There is no Chinese encoding problem.
Next, we use the same method to restore the data table to the MySQL 4.1 database. Note that during import
The code is gb2312, but an error occurred in phpMyAdmin. However, ignore the error and find that the table is still imported.
There is no problem with Chinese characters, but note that the PHP program must handle the problem like this; otherwise, there is a garbled problem.
<?
Header ("Content-Type: text/html; charset = uft-8 ");
Mysql_query ("set names utf8 ;");
Next, the MySQL statement is normal.
.....
?>