Mysql completely solve the Chinese garbled problem scheme (illegal mix of collations for operation) _mysql

Source: Internet
Author: User

MySQL often appears in the Chinese support unfriendly situation common error "illegal mix of collations for operation"

Let's do a regular set of what character sets are involved in the MySQL database

Character-set-server/default-character-set: Server character set, by default

Character-set-database: Database Character Set

Character-set-table: Database table Character Set

In general, you only need to set up character-set-server, and when you create databases and tables, you do not specifically specify character sets, so the character-set-server character set is used uniformly.

Character-set-client: Client's character set

Character-set-results: Result Character Set

On the client, if no character-set-results is defined, the character-set-client character set is used as the default character set

Below share a solution to the text character garbled in MySQL solution:

Modify MySQL Configuration

Vim/etc/mysql/my.cnf

Find the "Client" item:

The Yellow keyword above is the client we are looking for, followed by adding a row below: Default-character-set=utf8

Save exit configuration file.

Then shut down the MySQL service and reboot.

/etc/init.d/mysql Stop
/etc/init.d/mysql start

Then we go into MySQL and view 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 can see the character set default support UTF8, we are involved in Chinese characters when there is no garbled situation.

The above is a small set to introduce the MySQL completely solve the problem of Chinese garbled solution (illegal mix of collations for operation), I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Related Article

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.