Mysql provides a complete solution for Chinese Garbled text (Illegal mix of collations for operation) and illegalcollations

Source: Internet
Author: User

Mysql provides a complete solution for Chinese Garbled text (Illegal mix of collations for operation) and illegalcollations

Mysql often has unfriendly support for Chinese characters. The common error "Illegal mix of collations for operation"

The following describes the character sets involved in the mysql database.

Character-set-server/default-character-set: server character set, which is used by default.

Character-set-database: database character set

Character-set-table: character set of the database table

Generally, you only need to set character-set-server, but do not specify character sets when creating databases and tables. In this way, the character-set-server character set is used in a unified manner.

Character-set-client: character set of the client

Character-set-results: result character set

On the client side, if character-set-results is not defined, the character-set-client character set is used as the default character set.

The following is a solution to solve Chinese Character garbled characters in mysql:

Modify mysql configurations

Vim/etc/mysql/my. cnf

Search for "client:

The yellow keyword above is the client we are looking for, and then add a line below: default-character-set = utf8

Save and exit the configuration file.

Then close the mysql service and restart.

/etc/init.d/mysql stop/etc/init.d/mysql start

Then, go to mysql and check the character set.

mysql> show variables like 'character\_set\_%';+--------------------------+--------+| Variable_name | Value |+--------------------------+--------+| character_set_client | utf8 || character_set_connection | utf8 || character_set_database | utf8 || character_set_filesystem | binary || character_set_results | utf8 || character_set_server | utf8 || character_set_system | utf8 |+--------------------------+--------+7 rows in set (0.00 sec)

The above results show that the character set supports utf8 by default. We will not see garbled characters when it comes to Chinese characters.

The above is a small series of solutions for Mysql to completely solve Chinese Garbled text (Illegal mix of collations for operation), I hope to help you, if you have any questions, please leave a message and the editor will reply to you in time. Thank you very much for your support for the help House website!

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.