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 the debian system after a long time,The test is successful in debian 7.0, and 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