Home > Database > Mysql Tutorial > 重新restore了mysql到另一台机器上后mysql 编码问题报错

重新restore了mysql到另一台机器上后mysql 编码问题报错

WBOY
Release: 2016-06-07 18:05:57
Original
1088 people have browsed it

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

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

初步判断 应该是mysql的问题 [代研究本质问题]:
在my.ini 添加如下:
代码如下:
[client]
character-set-client = utf8
default-character-set = utf8
[mysqld]
character-set-server = utf8
character-set-filesystem = utf8[mysql]
init_connect='SET NAMES utf8'
[mysql]
default-character-set=utf8

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

查看创建mysql数据库的默认编码:
show create database db_name;
更改已经创建的db的编码:
alter database db_name character set utf8 collate utf8_general_ci;
查看数据库相关信息:
mysql>status
查看数据库相关信息2:
mysql> show variables like 'char%';
Related labels:
source:php.cn
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