Refer to the original tutorial: [Modify the mysql5.6 encoding method under Centos7 to solve the question mark in the website Chinese] (http://www.cnblogs.com/uncle-box/p/5791057.html)
Modify the MySQL database character encoding to UTF-8. UTF-8 contains the characters needed by all countries in the world and is an international encoding.
mysql -u root -p
enter password
View current mysql running status
mysql>status
Among them, server
and db
were originally not utf-8
; the default encoding is latin1
.
Default location: /etc/my.cnf
vim /etc/my.cnf
The picture is after I added the settings.
character-set-server=utf8
collation-server=utf8_general_ci
: wq! #Save and exit
systemctl restart mysql.service #Restart MySQL
mysql>status
At this time, all encodings should be UTF-8
haracter_set_client: The character set of the data requested by the client.
character_set_connection: The character set that receives data from the client and then transmits it.
character_set_database: The character set of the default database, no matter how the default database is changed, it is this character set; if there is no default database, the character set specified by character_set_server does not need to be set.
character_set_filesystem: Convert the file name on the operating system to this character set, that is, convert character_set_client to character_set_filesystem, and the default is binary.
character_set_results: The 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 and does not need to be set. The character set for storing system metadata.
Recommended Posts