Mysql cannot insert or display Chinese Characters In debian

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.