In the debian environment, the problem of mysql being unable to insert and display Chinese characters is completely solved. In Linux, Mysql inserts Chinese characters and displays garbled characters. Solution: mysql-uroot-p press enter and enter the password to enter mysql. The viewing status is as follows: by default, latin1 is used on the client and server, so garbled characters are displayed. Solution: mysqlusermydb; mysqlalterdatabase
In the debian environment, the problem of mysql being unable to insert and display Chinese characters is completely solved. In Linux, Mysql inserts Chinese characters and displays garbled characters. Solution: mysql-uroot-p press enter and enter the password to enter mysql. The viewing status is as follows: by default, latin1 is used on the client and server, so garbled characters are displayed. Solution: mysqluser mydb; mysqlalter database
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 to 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 are only applicable 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. (System before 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