Home > Database > Mysql Tutorial > django admin–mysql 编码问题报错_MySQL

django admin–mysql 编码问题报错_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:50:13
Original
1413 people have browsed it

Django

bitsCN.com

重新restore了mysql到另一台机器上,今天新写了一个app,发现在admin界面下一添加汉字就会报错如下:

Warning at /admin/assets/add/Incorrect string value: '/xE5/x93/x88/xD5/x92/x88...' for column 'Name' at row 1Request Method:	POSTRequest URL:	http://127.0.0.1:8000/admin/assets/add/Django Version:	1.2.3Exception Type:	WarningException Value:	Incorrect string value: '/xE5/x93/x88/xD5/x92/x88...' for column 'Name' at row 1Exception Location:	/usr/lib/pymodules/python2.7.1/MySQLdb/cursors.py in _warning_check, line 82Python Executable:	/usr/bin/pythonPython Version:	2.7.1
Copy after login

初步判断 应该是mysql的问题 [代研究本质问题]:

在my.ini 添加如下:

[client]character-set-client = utf8default-character-set = utf8[mysqld]character-set-server = utf8character-set-filesystem = utf8[mysql]init_connect='SET NAMES utf8'[mysql]default-character-set=utf8
Copy after login

重启mysql服务器,问题解决。

 

-------------------------------------------------------------------------------------

 

查看创建mysql数据库的默认编码:

show create database db_name;
Copy after login

更改已经创建的db的编码:

alter database db_name character set utf8 collate utf8_general_ci;
Copy after login

查看数据库相关信息:

mysql>status
Copy after login

查看数据库相关信息2:

mysql> show variables like’char%’;
Copy after login
bitsCN.com

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template