centos修改mysql字符集 解决中文乱码问题

时间:2022-09-22 22:29:23

1.修改 my.cnf mysql的配置文件

[client]
default-character-set=utf8
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

default-storage-engine=InnoDB
character-set-server=utf8
collation-server=utf8_general_ci
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

注意带utf8的三行。

2.关闭服务

service mysqld stop


3.重启服务

service mysqld start