1、修改my.ini文件
Windows路径:C:\ProgramData\MySQL\MySQL Server 5.7\my.ini
Linux路径:vim /etc/my.cnf
改为:
[client]
......
default-character-set=utf8
[mysql]
......
default-character-set=utf8
......
[mysqld]
character_set_server=utf8
......
2、重启服务
Windows: 控制面板->服务->MySQL57
Linux: service mysqld restart
3、查看结果
SHOW VARIABLES LIKE 'character%';
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\MySQL\MySQL Server 5.7\share\charsets\ |