Chinese garbled characters appear in mysql under centos system

王林
Release: 2020-03-20 14:29:46
Original
2140 people have browsed it

Chinese garbled characters appear in mysql under centos system

1. Log in to MySQL to view the character set using SHOW VARIABLES LIKE 'character%';, the display is as follows:

Chinese garbled characters appear in mysql under centos system

character_set_database and The default character set of character_set_server is still latin1.

(Recommended tutorial: centos usage tutorial)

Solution:

Just modify the character set key value in the my.cnf file of mysql .

1. Add default-character-set=utf8 in the [client] field, as follows:

[client]
default-character-set=utf8
Copy after login

2. Add character-set-server= in the [mysqld] field utf8, as follows:

[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
character-set-server=utf8
Copy after login

3. Add default-character-set=utf8 in the [mysql] field, as follows:

[mysql]
no-auto-rehash
default-character-set=utf8
Copy after login

After the modification is completed, execute the command service mysql restart Just restart the mysql service.

Note: There is a difference between the [mysqld] field and the [mysql] field.

Recommended related video tutorials: linux video tutorial

The above is the detailed content of Chinese garbled characters appear in mysql under centos system. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!