Created
December 27, 2013 04:37
-
-
Save Nataila/8142644 to your computer and use it in GitHub Desktop.
django中Mysql出现中文乱码问题(中文变成???)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
应该是mysql 默认编码问题。可以换 sqlite3 数据库,或者改下 /etc/mysql/my.cnf 配置文件,在 [client] 和 [mysqld] 下加如下项: | |
[client] | |
default-character-set=utf8 | |
[mysqld] | |
default-character-set=utf8 | |
default-collation=utf8_general_ci | |
character-set-server=utf8 | |
collation-server=utf8_general_ci | |
然后重启下 mysql,重新安装下 blog,没报错就 ok 了 | |
如果是django 需要drop database; | |
然后python manage.py syncdb | |
之后service mysqld restart | |
查看命令行进入mysql编码:SHOW VARIABLES LIKE 'character_set%'; | |
更改命令行模式编码: set character_set_results='utf8'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment