咨询热线:4006-75-4006
售前:9:00-23:30 备案:9:00-18:00 技术:7*24h
修改mysql 配置
vim /etc/mysql/my.cnf
查找 “client” 一项:
上面黄色关键词就是我们要找的 client, 紧接着在下面添加一行: default-character-set=utf8
保存退出配置文件.
然后关闭mysql服务,重新启动.
/etc/init.d/mysql stop /etc/init.d/mysql start
然后我们进入 mysql ,查看字符集
mysql> show variables like 'character\_set\_%'; +--------------------------+--------+ | 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 | +--------------------------+--------+ 7 rows in set (0.00 sec)
上面结果可以看到字符集默认支持 utf8,我们在涉及到汉字的时候不会有乱码的情况.