Modify the encoding method of MySQL5.6 in CentOS 7 to solve the Chinese display question mark of the website.

Source: Internet
Author: User
Tags character set centos mysql database

Solution:

In CentOS 7, modify MySQL database character encoding to UTF-8, which contains all the characters needed by all countries in the world, is an international code.

Specific operations:

1. Log on to the MySQL console.

Mysql-u root-p

Enter password

View the current mysql running status

Mysql> status


The last four encoding formats are changed, so UTF-8 is displayed. The default encoding type is latin1.

2. Modify the mysql configuration file

Default location:/etc/my. cnf

Go to The etc folder> vim my. cnf


The image is after I add the settings.

* My mysql does not have the [client] field. First, add the following code default-character-set = utf8 in the [client] section. (other setting statements are also mentioned online, it is a previous version, and is not used now)

* Add the following code in the [mysqld] section.

Character-set-server = utf8

Collation-server = utf8_general_ci

: Wq! # Save and exit

* Systemctl restart mysql. service # restart MySQL

* View the current mysql running status

Mysql> status

At this point all encoding should be UTF-8

Parameter description:

Haracter_set_client: character set of the client request data.

Character_set_connection: the character set that is received from the client and then transmitted.

Character_set_database: the character set of the default database. No matter how the default database changes, it is the character set. If no default database exists, set this parameter to the character set specified by character_set_server.

Character_set_filesystem: convert the file name in the operating system to this character set. That is, convert character_set_client to character_set_filesystem. The default value is binary.

Character_set_results: character set of the result set.

Character_set_server: the default character set of the database server.

Character_set_system: This value is always utf8. You do not need to set it. It stores the character set of system metadata.

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.