Basic situation:
System: CentOS 7
Mariadb installation Method: Yum
Garbled resolution process:
-
View current database encoding (after logging into the database)
# show variables like ‘character%‘;
(for already configured success)
-
You need to set the database configuration file if the result is not
-
Edit the/etc/my.cnf.d/client.cnf file and add the following:
[Client]
Default-character-set=utf8
-
Edit the/etc/my.cnf.d/mysql-clients.cnf file and add the following:
[MySQL]
Default-character-set=utf8
-
Edit the/etc/my.cnf file and add the following:
[Mysqld]
Character-set-server=utf8
Default-storage-engine=innodb
-
Restart Service
# systemctl restart mariadb
Run again # show variables like ' character% ';
As a result, the setting is successful.
However, if you insert Chinese in database that was created before setting, it is still garbled. Delete the re-creation of a database at this time.
The character set meaning of each option in the picture, see SUNZN ' blog
MARIADB inserting Chinese data garbled resolution process