重新restore了mysql到另一臺機器上后mysql 編碼問題報錯
更新時間:2011年12月17日 01:44:18 作者:
重新restore了mysql到另一臺機器上,今天新寫了一個app,發(fā)現(xiàn)在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的問題 [代研究本質(zhì)問題]:
在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服務(wù)器,問題解決。
查看創(chuàng)建mysql數(shù)據(jù)庫的默認編碼:
show create database db_name;
更改已經(jīng)創(chuàng)建的db的編碼:
alter database db_name character set utf8 collate utf8_general_ci;
查看數(shù)據(jù)庫相關(guān)信息:
mysql>status
查看數(shù)據(jù)庫相關(guān)信息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的問題 [代研究本質(zhì)問題]:
在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服務(wù)器,問題解決。
查看創(chuàng)建mysql數(shù)據(jù)庫的默認編碼:
show create database db_name;
更改已經(jīng)創(chuàng)建的db的編碼:
alter database db_name character set utf8 collate utf8_general_ci;
查看數(shù)據(jù)庫相關(guān)信息:
mysql>status
查看數(shù)據(jù)庫相關(guān)信息2:
mysql> show variables like 'char%';
相關(guān)文章
Mysql查詢數(shù)據(jù)庫或數(shù)據(jù)表中的數(shù)據(jù)量以及數(shù)據(jù)大小
許多數(shù)據(jù)庫的元數(shù)據(jù)都是存儲在mysql中的,本文主要介紹了Mysql查詢數(shù)據(jù)庫或數(shù)據(jù)表中的數(shù)據(jù)量以及數(shù)據(jù)大小,文中通過示例代碼介紹的非常詳細,需要的朋友們下面隨著小編來一起學習學習吧2024-02-02mysql 有關(guān)“InnoDB Error ib_logfile0 of different size”錯誤
mysql 有關(guān)“InnoDB Error ib_logfile0 of different size”錯誤的解決方法,需要的朋友可以參考下。2011-06-06CentOS系統(tǒng)中MySQL5.1升級至5.5.36
有相關(guān)測試數(shù)據(jù)說明從5.1到5.5+,MySQL性能會有明顯的提升,具體的需要自己建立測試環(huán)境去實踐下,今天我們就來操作下,并記錄下來升級的具體步驟2017-07-07DDL數(shù)據(jù)庫與表的創(chuàng)建和管理深入講解使用教程
這篇文章主要介紹了DDL數(shù)據(jù)庫與表的創(chuàng)建和管理,系統(tǒng)架構(gòu)的層面來看,數(shù)據(jù)庫從大到小依次是數(shù)據(jù)庫服務(wù)器(上面安裝了DBMS和數(shù)據(jù)庫)、數(shù)據(jù)庫(也稱database或者schema)、數(shù)據(jù)表、數(shù)據(jù)表的行與列2023-04-04