Mysql 字符集引數翻譯

fudaliang1999發表於2013-11-08
來之Mysql5.6 官方文件
Variable Name character_set_client
Variable Scope Global, Session
Dynamic Variable Yes
  Permitted Values
Type string

          The character set for statements that arrive from the client.          The session value of this variable is set using the character          set requested by the client when the client connects to the          server. (Many clients support a           --default-character-set option to enable this          character set to be specified explicitly. See also           .) The global value of the          variable is used to set the session value in cases when the          client-requested value is unknown or not available, or the          server is configured to ignore client requests:

  •               The client is from a version of MySQL older than MySQL              4.1, and thus does not request a character set.            

  •                The client requests a character set not known to the              server. For example, a Japanese-enabled client requests               sjis when connecting to a server not              configured with sjis support.            

  • was started with the                             option, which causes it to ignore client character set              configuration. This reproduces MySQL 4.0 behavior and is              useful should you wish to upgrade the server without              upgrading all the clients.

ucs2, utf16,           utf16le, and utf32          cannot be used as a client character set, which means that          they also do not work for SET NAMES or           SET CHARACTER SET.       

Charcter_set_client引數用來指定客戶端向伺服器傳輸語句時使用的字符集。這個變數用來設定客戶端連線伺服器時使用的字符集(很多客戶端支援--default-character-set
屬性,用來顯示指定字符集)。這個引數在全域性變數設定時,用來給那些沒有顯示設定字符集(或者字符集不對)的客戶端使用:Mysql4.1 之前版本不支援這個引數是使用系統預設值;伺服器不能接受客戶端字符集是使用全家預設值;Mysqld程式透過 忽略設定時使用預設值。ucs2, utf16, utf16le, and utf32 不能被用作客戶端字符集。

  •  
    Variable Name character_set_connection
    Variable Scope Global, Session
    Dynamic Variable Yes
      Permitted Values
    Type string

              The character set used for literals that do not have a character set introducer and for number-to-string conversion.        
             這個引數用來做沒有指定字符集字元的預設值,用來做數字到字元轉換(直譯不順,沒有理解意思,後記簡單說明)

  •       

    Variable Name character_set_database
    Variable Scope Global, Session
    Dynamic Variable Yes
    Footnote This option is dynamic, but only the server should set this information. You should not set the value of this variable manually.
      Permitted Values
    Type string

              The character set used by the default database. The server          sets this variable whenever the default database changes. If          there is no default database, the variable has the same value          as .      
      預設資料庫使用的字符集。Sever在切換資料庫的時候設定這個引數,如果沒有預設資料庫,這個引數值和character_set_server一樣

  •  
    Command-Line Format --character-set-filesystem=name
    Option-File Format character-set-filesystem
    Option Sets Variable Yes,
    Variable Name character_set_filesystem
    Variable Scope Global, Session
    Dynamic Variable Yes
      Permitted Values
    Type string

              The file system character set. This variable is used to          interpret string literals that refer to file names, such as in          the and           statements and the           function. Such file          names are converted from           to                     before the file opening attempt occurs. The default value is           binary, which means that no conversion          occurs. For systems on which multi-byte file names are          permitted, a different value may be more appropriate. For          example, if the system represents file names using UTF-8, set           to           'utf8'.        
    系統字符集,mysql訪問檔案的時候根據這個字符集找檔案:比如load data infile select … into outfile 語句及loca_file函式;在沒有mysql開啟檔案前,將檔名從character_set_client to
    character_set_filesystem
    轉換。該引數預設值是binary,表示不需要進行轉換。對使用多位元組表示檔名的系統,設定其它字符集更合適。如系統使用utf-8字符集,這個引數也設定為utf8

  •  
    Variable Name character_set_results
    Variable Scope Global, Session
    Dynamic Variable Yes
      Permitted Values
    Type string

              The character set used for returning query results such as          result sets or error messages to the client.       
     這個引數用來指定伺服器給客戶端返回資料時使用的字符集。

  •  
    Command-Line Format --character-set-server
    Option-File Format character-set-server
    Option Sets Variable Yes,
    Variable Name character_set_server
    Variable Scope Global, Session
    Dynamic Variable Yes
      Permitted Values
    Type string

              The server's default character set.        Server預設字符集,如果建表的時候不指定字符集,就使用這個值。

  •  
    Variable Name character_set_system
    Variable Scope Global
    Dynamic Variable No
      Permitted Values
    Type string

              The character set used by the server for storing identifiers. The value is always utf8.  
     Server儲存識別符號使用的字符集,值是utf-8     

  •  
    Command-Line Format --character-sets-dir=path
    Option-File Format character-sets-dir=path
    Option Sets Variable Yes,
    Variable Name character-sets-dir
    Variable Scope Global
    Dynamic Variable No
      Permitted Values
    Type directory name

              The directory where character sets are installed.

    字符集檔案存放的目錄。一般不需要指定。

    後記:

    1. MySQL Server將請求資料從character_set_client轉換為character_set_connection

    2. 操作前將請求資料從character_set_connection轉換為內部操作字符集,其確定方法如下:

      使用每個資料欄位的CHARACTER SET設定值;

      若上述值不存在,則使用對應資料表的DEFAULT CHARACTER SET設定值

      若上述值不存在,則使用對應資料庫的DEFAULT CHARACTER SET設定值;

      若上述值不存在,則使用character_set_server設定值。

    3. 將操作結果從內部操作字符集轉換為character_set_results



  • 來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15711267/viewspace-776126/,如需轉載,請註明出處,否則將追究法律責任。

    相關文章