欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

mysql字符集查询与设置方法_MySQL

程序员文章站 2022-05-08 20:13:02
...
bitsCN.com 说到底mysql 乱码的根源是的 mysql 字符集设置不当的问题。

有关查看 mysql 字符集的命令。

包括查看 mysql 数据库服务器字符集、查看 mysql 数据库字符集,以及数据表和字段的字符集、当前安装的 mysql 所支持的字符集等。


一、查看 mysql 数据库服务器和数据库字符集。
  1. mysql> show variables like '%char%';
  2. +--------------------------+-------------------------------------+------
  3. | variable_name | value |......
  4. +--------------------------+-------------------------------------+------
  5. | character_set_client | utf8 |...... -- 客户端字符集
  6. | character_set_connection | utf8 |......
  7. | character_set_database | utf8 |...... -- 数据库字符集
  8. | character_set_filesystem | binary |......
  9. | character_set_results | utf8 |...... www.jbxue.com
  10. | character_set_server | utf8 |...... -- 服务器字符集
  11. | character_set_system | utf8 |......
  12. | character_sets_dir | d:/mysql server 5.0/share/charsets/ |......
  13. +--------------------------+-------------------------------------+------

二、查看 mysql 数据表(table) 的字符集。
  1. mysql> show table status from sqlstudy_db like '%countries%';
  2. +-----------+--------+---------+------------+------+-----------------+------
  3. | name | engine | version | row_format | rows | collation |......
  4. +-----------+--------+---------+------------+------+-----------------+------
  5. | countries | innodb | 10 | compact | 11 | utf8_general_ci |......
  6. +-----------+--------+---------+------------+------+-----------------+------

三、查看 mysql 数据列(column)的字符集。
  1. mysql> show full columns from countries;
  2. +----------------------+-------------+-----------------+--------
  3. | field | type | collation | .......
  4. +----------------------+-------------+-----------------+--------
  5. | countries_id | int(11) | null | .......
  6. | countries_name | varchar(64) | utf8_general_ci | .......
  7. | countries_iso_code_2 | char(2) | utf8_general_ci | .......
  8. | countries_iso_code_3 | char(3) | utf8_general_ci | .......
  9. | address_format_id | int(11) | null | .......
  10. +----------------------+-------------+-----------------+--------
  • mysql字符集查看与设置详解
  • Mysql字符集设置详解
  • 有关mysql字符集设定的知识总结
  • (图文)mysql字符集设置详解
    四、查看当前安装的 mysql 所支持的字符集。
    1. mysql> show charset;
    2. mysql> show char set;
    3. +----------+-----------------------------+---------------------+--------+
    4. | charset | description | default collation | maxlen |
    5. +----------+-----------------------------+---------------------+--------+
    6. | big5 | big5 traditional chinese | big5_chinese_ci | 2 |
    7. | dec8 | dec west european | dec8_swedish_ci | 1 |
    8. | cp850 | dos west european | cp850_general_ci | 1 |
    9. | hp8 | hp west european | hp8_english_ci | 1 |
    10. | koi8r | koi8-r relcom russian | koi8r_general_ci | 1 |
    11. | latin1 | cp1252 west european | latin1_swedish_ci | 1 |
    12. | latin2 | iso 8859-2 central european | latin2_general_ci | 1 |
    13. | swe7 | 7bit swedish | swe7_swedish_ci | 1 |
    14. | ascii | us ascii | ascii_general_ci | 1 |
    15. | ujis | euc-jp japanese | ujis_japanese_ci | 3 |
    16. | sjis | shift-jis japanese | sjis_japanese_ci | 2 |
    17. | hebrew | iso 8859-8 hebrew | hebrew_general_ci | 1 |
    18. | tis620 | tis620 thai | tis620_thai_ci | 1 |
    19. | euckr | euc-kr korean | euckr_korean_ci | 2 |
    20. | koi8u | koi8-u ukrainian | koi8u_general_ci | 1 |
    21. | gb2312 | gb2312 simplified chinese | gb2312_chinese_ci | 2 |
    22. | greek | iso 8859-7 greek | greek_general_ci | 1 |
    23. | cp1250 | windows central european | cp1250_general_ci | 1 |
    24. | gbk | gbk simplified chinese | gbk_chinese_ci | 2 |
    25. | latin5 | iso 8859-9 turkish | latin5_turkish_ci | 1 |
    26. | armscii8 | armscii-8 armenian | armscii8_general_ci | 1 |
    27. | utf8 | utf-8 unicode | utf8_general_ci | 3 |
    28. | ucs2 | ucs-2 unicode | ucs2_general_ci | 2 |
    29. | cp866 | dos russian | cp866_general_ci | 1 |
    30. | keybcs2 | dos kamenicky czech-slovak | keybcs2_general_ci | 1 |
    31. | macce | mac central european | macce_general_ci | 1 |
    32. | macroman | mac west european | macroman_general_ci | 1 |
    33. | cp852 | dos central european | cp852_general_ci | 1 |
    34. | latin7 | iso 8859-13 baltic | latin7_general_ci | 1 |
    35. | cp1251 | windows cyrillic | cp1251_general_ci | 1 |
    36. | cp1256 | windows arabic | cp1256_general_ci | 1 |
    37. | cp1257 | windows baltic | cp1257_general_ci | 1 |
    38. | binary | binary pseudo charset | binary | 1 |
    39. | geostd8 | geostd8 georgian | geostd8_general_ci | 1 |
    40. | cp932 | sjis for windows japanese | cp932_japanese_ci | 2 |
    41. | eucjpms | ujis for windows japanese | eucjpms_japanese_ci | 3 |
    42. +----------+-----------------------------+---------------------+--------+
    以上查看 mysql 字符集命令,适用于 windows & linux。
bitsCN.com