mysql查看編碼類型_第1頁
mysql查看編碼類型_第2頁
mysql查看編碼類型_第3頁
mysql查看編碼類型_第4頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、mysql 查看編碼方式專題一、 查看數(shù)據(jù)庫的字符集show variables like character_set_%; 輸出:+-+-+ | variable_name | value | +-+-+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set

2、_server | latin1 | | character_set_system | utf8 | +-+-+ 結(jié)合以下的編碼表我們發(fā)現(xiàn)當(dāng)前的數(shù)據(jù)庫系統(tǒng)的編碼:latin1_bin 西歐 (多語言 ), 二進(jìn)制binary 二進(jìn)制以上是我在linux 環(huán)境中的查看的結(jié)果編碼集了。我現(xiàn)在win 平臺(tái)上面查看編碼集結(jié)果如:+-+-+ | variable_name | value | +-+-+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 |

3、 | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | +-+-+ 為什么會(huì)出現(xiàn)不一致的情況呢?在我本機(jī)上面是顯示的utf-8. 而在 linux 上面居然是二、通過命令修改其編碼創(chuàng)建數(shù)據(jù)庫指定數(shù)據(jù)庫的字符集mysqlcreate database mydb character set utf-8;#直接指定其編碼直接通過命令進(jìn)行修改set character_set_client

4、=utf8; set character_set_connection=utf8; set character_set_database=utf8; set character_set_results=utf8; set character_set_server=utf8; 修改完了之后再查詢show variables like character_set_%; +-+-+ | variable_name | value | +-+-+ | character_set_client | utf8 | | character_set_connection | utf8 | | characte

5、r_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | +-+-+ 結(jié)果全部都調(diào)整修改成utf-8 了!修改完了之后我看 select * from address_address; 出現(xiàn)亂碼了! django 也亂碼三、解決數(shù)據(jù)導(dǎo)入導(dǎo)出的亂碼問題#create database nginxdjango; # use nginxdjan

6、go; # show variables like character_set_%; #打印輸出居然是如下+-+-+ | variable_name | value | +-+-+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | lat

7、in1 | | character_set_system | utf8 | +-+-+ 依舊是 latin 編碼的。ok。我將其編碼設(shè)置一下set character_set_client=utf8; set character_set_connection=utf8; set character_set_database=utf8; set character_set_results=utf8; set character_set_server=utf8; 再查詢一下其編碼格式為: +-+-+ | variable_name | value | +-+-+ | character_set_c

8、lient | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | +-+-+ 現(xiàn)在將數(shù)據(jù)導(dǎo)進(jìn)來source /python/django/sql/nginxdjango.sql; 其中的 nginxdjango.sql 其編碼

9、也是utf-8 格式的!導(dǎo)進(jìn)來 數(shù)據(jù)庫查看居然還是亂碼不過程序跑起來是正常了!mysql 字符集編碼的類型種類gb2312_chinese_ci和 gbk_chinese_ci以及 gb2312_bin,gbk_bin的區(qū)別gb2312_chinese_ci : 只支持簡體中文gb2312_bin :而 gb2312_bin可以說是 gb2312_chinese_ci的一個(gè)子集,而且 gb2312_bin是二進(jìn)制存儲(chǔ) .區(qū)分大小寫數(shù)據(jù)庫編碼格式就意義不一樣了gbk_chinese_ci 支持簡體中文和繁體gbk_bin 解釋同 gb2312_bin 對(duì)應(yīng) gbk_chinese_ci ps:g

10、bk 包括了簡體與繁體兩種類型新篇: 2010-03-09 mysql 中默認(rèn)字符集的設(shè)置有四級(jí):服務(wù)器級(jí),數(shù)據(jù)庫級(jí),表級(jí)。最終是 字段級(jí) 的字符集設(shè)置。注意前三種均為默認(rèn)設(shè)置,并不代碼你的字段最終會(huì)使用這個(gè)字符集設(shè)置。所以我們建議要用show create table table ; 或 show full fields from tablename; 來檢查當(dāng)前表中字段的字符集設(shè)置。mysql 中關(guān)于連接環(huán)境的字符集設(shè)置有 client 端, connection, results 通過這些參數(shù),mysql 就知道你的客戶端工具用的是什么字符集,結(jié)果集應(yīng)該是什么字符集。這樣mysql 就會(huì)

11、做必要的翻譯,一旦這些參數(shù)有誤,自然會(huì)導(dǎo)致字符串在轉(zhuǎn)輸過程中的轉(zhuǎn)換錯(cuò)誤?;旧?9% 的亂碼由些造成。1. 數(shù)據(jù)庫表中字段的字符集設(shè)置。show create table tablename或 show full columns from tablenamemysql show create table t1;mysql show full columns from t1; 查看列的編碼類型3. 查看數(shù)據(jù)庫的編碼格式show create database test; 輸出: create database test /*!40100 default character set utf8 */

12、 2. 當(dāng)前聯(lián)接系統(tǒng)參數(shù) show variables like char% mysql show variables like char%; 1. 中文,請(qǐng)確保表中該字段的字符集為中文兼容: big5 | big5 traditional chinese gb2312 | gb2312 simplified chinese gbk | gbk simplified chinese utf8 | utf-8 unicode 其它補(bǔ)充修改數(shù)據(jù)庫的字符集 mysqluse mydb mysqlalter database mydb character set utf-8; 創(chuàng)建數(shù)據(jù)庫指定數(shù)據(jù)庫的字符集 mysqlcreate database mydb character set utf-8; 2010-05-02 新添加進(jìn)來show variabl

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論