码迷,mamicode.com
首页 > 其他好文 > 详细

django-1366, "Incorrect string value: '\\xE6\\x88\\x9A\\xE4\\xBC\\x9F...'

时间:2016-04-17 13:15:02      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:

今天把之前的一些代码转移到另外一台电脑的时候,

python manage.py syncdb 

的时候报了

(1366, "Incorrect string value: ‘\\xE6\\x88\\x9A\\xE4\\xBC\\x9F...‘

的错误,查了一下,应该是数据库编码设置的问题,看了一下本机数据库的默认编码,果然如此

mysql> show variables like "%char%";
+--------------------------+--------------------------------------------------------+
| Variable_name            | Value                                                  |
+--------------------------+--------------------------------------------------------+
| character_set_client     | utf8                                                   |
| character_set_connection | utf8                                                   |
| character_set_database   | latin1                                                 |
| character_set_filesystem | binary                                                 |
| character_set_results    | utf8                                                   |
| character_set_server     | latin1                                                 |
| character_set_system     | utf8                                                   |
| character_sets_dir       | /usr/local/mysql-5.7.11-osx10.9-x86_64/share/charsets/ |
+--------------------------+--------------------------------------------------------+
8 rows in set (0.01 sec)

mysql> set character_set_database=utf8;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> set character_set_server=utf8;
Query OK, 0 rows affected (0.00 sec)

把latin1的那两个编码改为utf8就没问题了

django-1366, "Incorrect string value: '\\xE6\\x88\\x9A\\xE4\\xBC\\x9F...'

标签:

原文地址:http://www.cnblogs.com/qwj-sysu/p/5400705.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!