Django前端输入中文后MySQL出现中文乱码
Django前端输入中文后MySQL出现中文乱码
注:需完全一致,当初我数据库用的是 gbk , django 用的 utf8 结果依然是乱码,统一成 utf8 后就好了。
附: MySQL 控制台修改字符集
首先查看当前 MySQL 字符集
mysql> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
然后逐个变量设置
mysql> SET character_set_client='utf8';
mysql> SET character_set_connection='utf8';
mysql> SET character_set_results='utf8';
……
阅读量 -