Mysql cannot insert Chinese characters into debian systems. ultimate solution _ MySQL

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

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.