linux修改mysql默认字符编码的过程

centos6.4自带的mysql
1. su -      切换到root
2. mv /etc/ my.cnf /etc/my.cnf~
3. cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
4. vim /etc/my.cnf
5.在[client]下加上一行:default-character-set=utf8
6.在[mysql]下加上一行:default-character-set=utf8
7. 在[mysqld]下加上几行:default-character-set=utf8
            collation-server=utf8_unicode_ci
                                                init-connect='SET NAMES utf8'
                                          character-set-server=utf8
8. 保存退出
9. service mysqld restart
ok!
查看字符编码:进入mysql输入:show variables like'character%';




你可能感兴趣的:(linux)