Mysql cannot insert Chinese characters in the debian system. the ultimate solution is debian.
BitsCN.com
In the debian environment, the problem that mysql cannot insert or display Chinese characters is completely solved.
How to insert Chinese characters into Mysql in Linux
Mysql-uroot-p press enter to enter the password
Enter mysql to view the status as follows:
By default, latin1 is used on the client and server, so garbled characters are displayed.
Solution:
Mysql> user mydb;
Mysql> alter database mydb character set utf8 ;!
As mentioned above, we used a temporary method to change the character set settings of the database and display Chinese characters. However, it was later found that some systems could not succeed.
For example, I used debian 7.0 and finally found a solution suitable for debian systems after a long time. the test was successful in debian 7.0, other methods, such as modifying the client and mysql to add default-character-set = utf8,Applicable only to systems earlier than 5.5!
The ultimate solution:
Modify the mysql string in debian to utf8 (refer to the "rainysia" column)
1. log on to mysql (mysql-uroot-p) and check the current database character set (status ;)
II. view the current system version (lsb_release-)
III. # vim/etc/mysql/my. cnf.(Systems earlier than 5.5)Add default-character-set = utf8 under [client]
Add default-character-set = utf8 under mysqld
Notice: If the error cannot be reported after modification, change default-character-set = utf8 to character_set_server = utf8. you do not need to add the default-character-set = utf8 parameter to the. client under mysqld.
IV. # vim/etc/mysql/my. cnf.(After December 5.5:
[Client]
Default-character-set = utf8
[Mysqld]
Default-storage-engine = INNODB
Character-set-server = utf8
Collation-server = utf8_general_ci
5. restart mysql (/etc/init. d/mysql stop/etc/init. d/mysql start)
6. after successful modification, go to mysql to view the character set (mysql> show variables like 'character _ set _ % ';)
Mysql cannot insert Chinese characters
BitsCN.com