重新restore了mysql到另一台机器上后mysql 编码问题报错
程序员文章站
2023-12-18 14:29:46
如下: 复制代码 代码如下: warning at /admin/assets/add/ incorrect string value: '\xe5\x93\x88\xd5...
如下:
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%';
复制代码 代码如下:
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%';