设置MySQL数据库编码为UTF-8
登陆后查看数据库当前编码:SHOW VARIABLES LIKE 'char%';
修改/etc/mysql/my.cnf (默认安装路径下) (标签下没有的添加,有的修改)
[mysqld]
character_set_server=utf8
[mysql]
default-character-set= utf8
[client]
default-character-set = utf8
重启MySQL服务
service mysql stop;
service mysql start;