[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
重启
[root@localhost~]# systemctl restart mariadb
mysql -u root -p 后查看现在的字符编码
show variables like '%character%';