1.在
mysql压缩目录下,有一堆的参数配置文件,比如:my-small.ini,复制一下这个文件,自己改下名字,比如叫:my.ini
2.打开my.ini文件,增加如下参数:
[client]:增加default-character-set=utf8参数
[client]
#password = [your_password]
port = 3306
socket = /tmp/mysql.sock
default-character-set=utf8
[mysqld]:增加如下3个参数
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
# generic configuration options
port = 3306
socket = /tmp/mysql.sock
3.设置完成后,重启下mysql服务
4.连接上你的数据库之后,输入命令:SHOW VARIABLES LIKE '%char%';即可查看到现在你的数据库所使用的字符集了
mysql> SHOW VARIABLES LIKE '%char%';
+--------------------------+---------------------------------------------------------+
| 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 | E:\Program Files\MySQL\MySQL Server 5.5\share\charsets\ |
+--------------------------+---------------------------------------------------------+
8 rows in set