1、查看编码格式
show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
-
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
2、复制my-large.cnf文件到/etc/my.cnf
cp /usr/share/doc/mysql-server-4.1.12/my-large.cnf /etc/my.cnf
3、打开my.cnf修改编码
vi /etc/my.cnf
在[mysqld]下添加
default-character-set=utf8
在[client]下添加
default-character-set=utf8
4、重启MySQL服务
service mysqld restert
5、登录mysql看看修改成功否
show variables like 'character%';
+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
如果显示以上信息表示修改成功了