MySQL 5.5客戶端字符集相關引數

feelpurple發表於2016-04-08
character_set_client 在客戶端發出SQL語句所使用的字符集。

collation_connection 連線所使用的字符集校對規則

character_set_results 返回到客戶端的查詢結果集(例如查詢結果或錯誤資訊)所使用的字符集

character_set_connection The character set used for literals that do not have a character set introducer and for number-to-string conversion

--指定客戶端當前會話使用的字符集

SET NAMES會同時更改character_set_client, character_set_connection,character_set_results這三個會話引數的字符集

mysql> set names utf8;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%character%';
+--------------------------+-----------------------+
| Variable_name            | Value                 |
+--------------------------+-----------------------+
| character_set_client     | utf8                  |
| character_set_connection | utf8                  |
| character_set_database   | gbk                   |
| character_set_filesystem | binary                |
| character_set_results    | utf8                  |
| character_set_server     | gbk                   |
| character_set_system     | utf8                  |
| character_sets_dir       | /data/share/charsets/ |
+--------------------------+-----------------------+
8 rows in set (0.00 sec)

SET CHARACTER SET會更改character_set_client、character_set_results,同時將character_set_connection設定為character_set_database這個系統引數的值

mysql> set character set latin2;
Query OK, 0 rows affected (0.01 sec)

mysql> show variables like '%character%';
+--------------------------+-----------------------+
| Variable_name            | Value                 |
+--------------------------+-----------------------+
| character_set_client     | latin2                |
| character_set_connection | gbk                   |
| character_set_database   | gbk                   |
| character_set_filesystem | binary                |
| character_set_results    | latin2                |
| character_set_server     | gbk                   |
| character_set_system     | utf8                  |
| character_sets_dir       | /data/share/charsets/ |
+--------------------------+-----------------------+
8 rows in set (0.00 sec)

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

相關文章