第一步:查看mysql根目录的my.ini是否修改成功
将default-character-set=latin1 修改成 default-character-set=utf8
character-set-server=utf8 修改成 character-set-server=utf8
(修改保存后,需要重启mysql)
字符不同的话,需要修改成相同字符
set collation_connection = utf8_general_ci(或utf8_unicode_ci)
第二步:输入sql命令,查看mysql字符集设置
mysql>show variables like "%char%";
+--------------------------+---------------------------------------------------------+
| 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 | C:\Program Files\MySQL\MySQL Server 5.5\share\charsets\ |
+--------------------------+---------------------------------------------------------+
如果不是utf8格式,则需要修改成utf8。
sql命令:set character_set_client = utf8;
再查看具体字符,输入sql命令:show variables like "%coll%";
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+