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!