Solution to centos mariadb garbled code: 1. Add "character-set-server=utf8" under the [mysqld] label; 2. Add "default-character-set=utf8" under the [client] label ; 3. Restart the service.
The operating environment of this article: CentOS 7 system, Dell G3 computer.
How to solve the centos mariadb garbled problem?
CentOS 7 configure MariaDB (MySQL) character encoding to prevent Chinese garbled characters
[root@localhost~]# vi /etc/my.cnf (如果不行则sudo vi /etc/my.cnf) #在[mysqld]标签下添加 character-set-server=utf8 [root@localhost~]# vi /etc/my.cnf.d/client.cnf #在[client]标签下添加 default-character-set=utf8
Restart
[root@localhost~]# systemctl restart mariadb mysql -u root -p 后查看现在的字符编码 show variables like '%character%';
Recommended tutorial: "centos tutorial"
The above is the detailed content of How to solve centos mariadb garbled problem. For more information, please follow other related articles on the PHP Chinese website!