修改前是这个样子的
mysql> show variables like "%char%";
+--------------------------+---------------------------------------------------------------+
| Variable_name | Value |
+--------------------------+---------------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | C:\Program Files (x86)\MySQL\MySQL Server 5.5\share\charsets\ |
+--------------------------+---------------------------------------------------------------+
8 rows in set
具体到my.ini中的配置是这样的:
若想更改,手动修改为utf-8好像不起作用。
怎么办呢?在MySQL的安装文件中进入bin目录下,双击MySQLInstanceConfig.exe,重新走一遍server的配置,一切默认就行,只需要在Character Set环节,要选择character为utf8
再来看配置文件:
变成utf-8了,顺道去数据库看看
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 | C:\Program Files (x86)\MySQL\MySQL Server 5.5\share\charsets\ |
+--------------------------+---------------------------------------------------------------+
8 rows in set
以后再新建数据库默认编码就是utf-8了,还在等什么,赶紧动手试试