如下:
複製代碼 代碼如下: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%';