MySQL Default character Set issues

Source: Internet
Author: User

Recently, when using MySQL, there was a strange problem with garbled characters, and I started to see that there were some problems with the MySQL character set.

Modified configuration file/etc/my.cnf

[mysqld]character-set-server=utf8

> Show variables like "character%";
+--------------------------+----------------------------+
| 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 |
| Character_sets_dir | /usr/share/mysql/charsets/|
+--------------------------+----------------------------+

But found that did not solve the problem of garbled, and find the relevant information found, in fact, MySQL UTF8 character set, our domestic default choice: Utf8_general_ci instead of utf8_unicode_ci, but the utf8 of the terminal is Utf8_unicode_ Ci
So this creates a conflict, and then modifies the configuration file.

[mysqld]init_connect=‘SET collation_connection = utf8_unicode_ci‘init_connect=‘SET NAMES utf8‘character-set-server=utf8collation-server=utf8_unicode_ci

After the modification, the program still does not solve the garbled problem.
After observation, it was found that although the configuration file was set, the character set will change strangely after each startup of MySQL.
The configuration file is then modified again.

[mysqld]init_connect=‘SET collation_connection = utf8_unicode_ci‘init_connect=‘SET NAMES utf8‘character-set-server=utf8collation-server=utf8_unicode_ciskip-character-set-client-handshake

Skip-character-set-client-handshake skips characters to set the client handshake.
The documentation is explained below

--character-set-client-handshakeDon‘t ignore character set information sent by the client. To ignore client information and use the default server character set, use --skip-character-set-client-handshake; this makes MySQL behave like MySQL 4.0

MySQL Default character Set issues

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.