改变mysql默认字符集为utf8

问题:在使用mysql时,使用php插入数据库、查询数据库信息会出现乱码
解决:修改mysql配置文件,在其配置文件中加入一下代码
init_connect=‘SET collation_connection = utf8_unicode_ci’

init_connect=‘SET NAMES utf8’

character-set-server=utf8

collation-server=utf8_unicode_ci

skip-character-set-client-handshake

修改完成后,重启mysql服务器即可
重启之后在终端下查看字符集,结果如下:

原文地址:https://www.cnblogs.com/tm2015/p/4976811.html