Solve the problem of Chinese garbled characters in Mysql5.7 and Chinese garbled characters in mysql5.7

Source: Internet
Author: User

Solve the problem of Chinese garbled characters in Mysql5.7 and Chinese garbled characters in mysql5.7

When using mysql5.7, you will find garbled characters appear after you write Chinese characters to the database through the web end. However, after you directly insert data using SQL statements in the database, the Chinese characters are displayed normally, how can this problem be solved? The data encoding process and principles of MySQL are not described here. If you are interested, you can use Baidu.

The following operations are available:

1. Open the mysql console and enter the command show variables like 'character % ';

Shown as follows:

 +--------------------------+-------------------------------------------+| Variable_name      | Value                   |+--------------------------+-------------------------------------------+| character_set_client   | latin1                  || character_set_connection | latin1                  || character_set_database  | utf8                   || character_set_results  | latin1                  || character_set_server   | utf8                   || character_set_system   | utf8                   || character_sets_dir    | C:\MySQL\MySQL Server 5.0\share\charsets\ |+--------------------------+-------------------------------------------+

2. Modify the my. ini file

 [client]  default-character-set=utf8  [mysqld]  default-storage-engine=INNODB  character-set-server=utf8  collation-server=utf8_general_ci

3. Run the command in step 1 After restart as follows:

  +--------------------------+----------------------------+| Variable_name | Value |+--------------------------+----------------------------+| character_set_client | utf8 || character_set_connection | utf8 || character_set_database | latin1 || character_set_filesystem | binary || character_set_results | utf8 || character_set_server | latin1 || character_set_system | utf8 || character_sets_dir | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+

The default Character Set of character_set_database and character_set_server is latin1.

4. Enter the command: set names utf8;

After the restart, run the following command:

+--------------------------+------------------------------------------------+| 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 | C:\wamp64\bin\mysql\mysql5.7.9\share\charsets\ |+--------------------------+------------------------------------------------+

Except character_set_filesystem is binary, all others are utf8,

In this way, you can enter the database normally by setting utf8 encoding on the web end.

The above section describes how to solve the problem of Mysql5.7 Chinese garbled characters. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.