日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Mysql設(shè)置字符編碼的方法

Mysql設(shè)置字符編碼可以解決一些常見的問題,比如使用不同的字符集出錯的問題,下面就是Mysql設(shè)置字符編碼解決該問題的具體介紹。

錯誤是在你的結(jié)果集中有兩種字符集。

比如說你在兩個表聯(lián)合查詢,一個表的字符集是latin1,另一個是utf8,
這樣在你的結(jié)果集中有兩種字符集,mysql會報錯誤。

一個表中不同的字段使用不同的字符集,也是一個道理。

用SHOW   CREATE   TABLE   table_name;可以看出具體的字符集設(shè)置。

查了幫助手冊,說是user的字符集沒有設(shè),默認為utf8,將其轉(zhuǎn)為latin1或gb2312等字符集

解決方法:

將不同的字符集,轉(zhuǎn)化成統(tǒng)一的字符集。  下面就是Mysql設(shè)置字符編碼的方法。

 
 
 
  1. After   an   upgrade   to   MySQL   4.1,   the   statement   fails:       
  2.  
  3. mysql>   SELECT   SUBSTRING_INDEX(USER(),'@',1);     
  4.  
  5. ERROR   1267   (HY000):   Illegal   mix   of   collations     
  6.  
  7. (utf8_general_ci,IMPLICIT)   and   (latin1_swedish_ci,COERCIBLE)     
  8.  
  9. for   operation   'substr_index'     
  10.  
  11. The   reason   this   occurs   is   that   usernames   are   stored   using   UTF8   (see   section   11.6   UTF8   for   Metadata).   As   a   result,   the   USER()   function   and   the   literal   string   '@'   have   different   character   sets   (and   thus   different   collations):       
  12.  
  13. mysql>   SELECT   COLLATION(USER()),   COLLATION('@');     
  14.  
  15. +-------------------+-------------------+     
  16.  
  17. |   COLLATION(USER())   |   COLLATION('@')         |     
  18.  
  19. +-------------------+-------------------+     
  20.  
  21. |   utf8_general_ci       |   latin1_swedish_ci   |     
  22.  
  23. +-------------------+-------------------+     
  24.  
  25. One   way   to   deal   with   this   is   to   tell   MySQL   to   interpret   the   literal   string   as   utf8:       
  26.  
  27. mysql>   SELECT   SUBSTRING_INDEX(USER(),_utf8'@',1);     
  28.  
  29. +------------------------------------+     
  30.  
  31. |   SUBSTRING_INDEX(USER(),_utf8'@',1)   |     
  32.  
  33. +------------------------------------+     
  34.  
  35. |   root                                                               |     
  36.  
  37. +------------------------------------+     
  38.  
  39. Another   way   is   to   change   the   connection   character   set   and   collation   to   utf8.   You   can   do   that   with   SET   NAMES   'utf8'   or   by   setting   the   character_set_connection   and   collation_connection   system   variables   directly.       

表的編碼轉(zhuǎn)換可以用:(MySQL   Version   >   4.12)

 
 
 
  1. ALTER   TABLE   tbl_name   CONVERT   TO   CHARACTER   SET   charset_name;    

之前的版本可以用:

 
 
 
  1. ALTER   TABLE   tbl_name   CHARACTER   SET   charset_name; 

【編輯推薦】

mysql修改字段的語句寫法

MySQL中多表刪除方法

詳解MySQL如何鏈接遠程SQL

MySQL集群簡介與配置詳解

MySQL數(shù)據(jù)庫的23個特別注意事項


網(wǎng)站題目:Mysql設(shè)置字符編碼的方法
網(wǎng)頁網(wǎng)址:http://www.5511xx.com/article/dppishh.html