mysql数据库设置编码utf8

我下载的是安装包mysql-installer-community-5.7.25.0.msi,只安装了MySQLserver

更改安装根目录下my.ini

在下面更改或添加如下

[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
character_set_server = utf8

更改完成重启mysql

查看编码

mysql>showvariableslike"%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       | E:\tools\developTool\MySQL\MySQL Server 5.7\share\charsets\ |
+--------------------------+-------------------------------------------------------------+

不知道是什么刚改完重启后

character_set_database项与character_set_server项的编码一直是latin1,后来

在[mysqld]项下default-character-set=utf8结果mysql服务不能启动了,后来又把此项删去了,再次启动就都变成utf8了

相关推荐