In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
How to query character encodings in mysql5.5? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!
In mysql5.5, you can query the character encoding through the "SHOW VARIABLES LIKE 'character%';" statement, which can display the character set used by the MySQL client, the character set used when connecting to the database, the character set used to create the database, the character set used by the database system, and so on.
Character is the general name of letters, numbers and symbols in the computer. A character can be a Chinese character, an English letter, an Arabic numeral, a punctuation mark and so on.
Computers store data in binary form. The numbers, English, punctuation, Chinese characters and other characters we see on the display are all the results of binary number conversion.
The character set (Character set) defines the correspondence between characters and binaries and assigns a unique number to the characters. Common character sets are ASCII, GBK, IOS-8859-1 and so on.
Character encoding (Character encoding), also known as a word set code, specifies how the number of characters is stored in a computer.
Most character sets correspond to only one character encoding, such as ASCII, IOS-8859-1, GB2312, GBK, which represents both the character set and the corresponding character encoding. Therefore, in general, the two can be regarded as synonyms. With the exception of the Unicode character set, Unicode has three encoding schemes, namely UTF-8, UTF-16, and UTF-32. The most commonly used is UTF-8 coding.
In MySQL, you can view the character set currently used by MySQL through the SHOW VARIABLES LIKE 'character%'; command, and the command and run results are as follows:
Mysql > SHOW VARIABLES LIKE 'character%' +-- +-- + | Variable_name | Value | | +-- +-- + | character_set_client | gbk | | | character_set_connection | gbk | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | gbk | | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | C:\ Program Files\ MySQL\ MySQL Server 5.7\ share\ charsets\ | +- -+-+ 8 rows in set 1 warning (0.01 sec)
The above running results are shown in the following table:
The name describes the character set used by the character_set_clientMySQL client when character_set_connection connects to the database. The character set used by the character_set_filesystemMySQL server file system to create the database. The default value is binary. The character set used by the character_set_serverMySQL server when returning data to the client does not do any conversion. It is recommended that the character set used by the character_set_serverMySQL server be managed by the system itself. Do not artificially define the character set used by the character_set_system database system. The default value is utf8. You do not need to set the installation directory of the character_sets_dir character set.
When garbled, you do not need to care about the three system variables character_set_filesystem, character_set_system and character_sets_dir, which will not affect garbled.
In MySQL, the command and execution procedure to view the available character sets is as follows:
Mysql > SHOW CHARACTER set +-+ | Charset | Description | Default collation | Maxlen | +-+- -+ | big5 | Big5 Traditional Chinese | big5_chinese_ci | 2 | | dec8 | DEC West European | dec8_swedish_ci | 1 | | cp850 | DOS West European | cp850_general _ ci | 1 | | hp8 | HP West European | hp8_english_ci | 1 | | koi8r | KOI8-R Relcom Russian | koi8r_general_ci | 1 | | latin1 | cp1252 West European | latin1_swedish_ci | 1 | latin2 | ISO 8859-2 Central European | latin2_general_ci | 1 | swe7 | 7bit Swedish | | swe7_swedish_ci | 1 | ascii | US ASCII | ascii_general_ci | 1 | | ujis | EUC-JP Japanese | ujis_japanese_ci | 3 | | sjis | Shift-JIS Japanese | sjis_japanese_ci | 2 | | hebrew | ISO 8859-8 Hebrew | hebrew_general_ci | 1 | | tis620 | TIS620 Thai | tis620_thai_ci | 1 | | euckr | EUC-KR Korean | euckr_korean_ci | 2 | | koi8u | KOI8-U Ukrainian | koi8u_general_ci | 1 | | gb2312 | GB2312 Simplified Chinese | gb2312_chinese_ci | 2 | | greek | ISO 8859-7 Greek | | | greek_general_ci | 1 | cp1250 | Windows Central European | cp1250_general_ci | 1 | | gbk | GBK Simplified Chinese | gbk_chinese_ci | 2 | | latin5 | ISO 8859-9 Turkish | latin5_turkish_ci | 1 | | armscii8 | ARMSCII-8 Armenian | armscii8_general_ci | 1 | utf8 | UTF-8 Unicode | | | utf8_general_ci | 3 | ucs2 | UCS-2 Unicode | ucs2_general_ci | 2 | | cp866 | DOS Russian | cp866_general_ci | 1 | | keybcs2 | DOS Kamenicky Czech-Slovak | keybcs2_general_ci | 1 | | macce | Mac Central European | macce_general_ci | 1 | | macroman | Mac West European | macroman_general_ci | 1 | | cp852 | DOS Central European | cp852_general_ci | 1 | | latin7 | ISO 8859-13 Baltic | latin7_general_ci | 1 | utf8mb4 | UTF-8 Unicode | utf8mb4_general_ci | 4 | | cp1251 | Windows Cyrillic | cp1251_general_ci | 1 | | Utf16 | UTF-16 Unicode | utf16_general_ci | 4 | | utf16le | UTF-16LE Unicode | utf16le_general_ci | 4 | | cp1256 | Windows Arabic | cp1256_general_ci | 1 | cp1257 | Windows Baltic | cp1257_general_ci | 1 | | utf32 | UTF-32 Unicode | utf32_general _ ci | 4 | | binary | Binary pseudo charset | binary | 1 | | geostd8 | GEOSTD8 Georgian | geostd8_general_ci | 1 | | cp932 | SJIS for Windows Japanese | cp932_japanese_ci | 2 | eucjpms | UJIS for Windows Japanese | eucjpms_japanese_ci | 3 | | gb18030 | China National Standard GB18030 | gb18030_chinese_ci | 4 | +- -+-- + 41 rows in set (0.02 sec)
Where:
The first column (Charset) is the character set name
The second column (Description) is the character set description
The third column (Default collation) is the default proofreading rule for the character set
The fourth column (Maxlen) represents the maximum number of bytes occupied by one character in the character set.
The common character sets are as follows:
Latin1 supports Western European characters, Greek characters, etc.
Gbk supports simplified Chinese characters.
Big5 supports traditional Chinese characters.
Utf8 supports characters from almost all countries.
Thank you for reading! After reading the above, do you have a general understanding of the method of querying character encodings in mysql5.5? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.