当前位置:Gxlcms > mysql > linux上设置mysql编码

linux上设置mysql编码

时间:2021-07-01 10:21:17 帮助过:78人阅读

linux下设置mysql编码

linux下设置mysql编码

首先查找MySql的cnf文件的位置:

[root@flyHome gaoxiang]# find / -iname '*.cnf' -print

/etc/pki/tls/openssl.cnf

/etc/my.cnf

/usr/share/openvpn/easy-rsa/2.0/openssl-0.9.6.cnf

/usr/share/openvpn/easy-rsa/2.0/openssl.cnf

/usr/share/openvpn/easy-rsa/1.0/openssl.cnf

/usr/share/mysql/my-small.cnf

/usr/share/mysql/my-large.cnf

/usr/share/mysql/my-innodb-heavy-4G.cnf

/usr/share/mysql/my-huge.cnf

/usr/share/mysql/my-medium.cnf

/usr/share/doc/mysql-server-5.5.18/my-small.cnf

/usr/share/doc/mysql-server-5.5.18/my-large.cnf

/usr/share/doc/mysql-server-5.5.18/my-innodb-heavy-4G.cnf

/usr/share/doc/mysql-server-5.5.18/my-huge.cnf

/usr/share/doc/mysql-server-5.5.18/my-medium.cnf

然后拷贝my-small.cnf、my-medium.cnf、my-huge.cnf、my-innodb-heavy-4G.cnf 其中一个到 /etc/my.cnf 下

[root@flyHome gaoxiang]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnfcp:是否覆盖"/etc/my.cnf"? y

再修改my.cnf

[root@flyHome gaoxiang]# vi /etc/my.cnf

在[client]下添加

default-charater-set=utf8

在[mysqld]下添加

collation_server = utf8_general_ci

character_set_server = utf8

保存退出后重启mysqld:

[root@flyHome gaoxiang]#service mysqld restart

完成以上的操作就OK了。

看一下效果:

mysql> show variables like 'character_set_%';

+--------------------------+----------------------------+

| Variable_name | Value |

+--------------------------+----------------------------+

| character_set_client | utf8 |

| character_set_connection | utf8 |

| character_set_database | utf8 |

| character_set_filesystem | binary |

| character_set_results | utf8 |

| character_set_server | utf8 |

| character_set_system | utf8 |

| character_sets_dir | /usr/share/mysql/charsets/ |

+--------------------------+----------------------------+

人气教程排行