修改mysqlcharacter_set_database与character_set_server的默认编码(windows环境)
修改前是这个样子的
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了,还在等什么,赶紧动手试试
本文来自博客园,作者:每天都要学一点,欢迎讨论和转载,转载请注明原文链接:https://www.cnblogs.com/yanan7890/p/7245324.html