答案 0 :(得分:2)
我找到了解决方案:
并且应该确保表格结构字段的编码。
如果要更改mysql的代码集,找到mysql安装位置,找到mysql的配置文件(my.cnf
)
在[client]
下,添加以下配置:
default-character-set=utf8
init_connect='SET NAMES utf8'
并重新启动mysql。
所以在mysql中确保:
>show variables like 'character%';
+--------------------------+----------------------------+
| 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 | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
然后就不会有乱码了。