In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces how to modify the mysql5.5.10 default character set and character encoding settings in windows. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
1. Find the my.cnf configuration file
If there is no my.cnf configuration file in the / etc/ directory, find the * .cnf file under / usr/share/mysql/ and copy one of them to / etc/ and rename it to my.cnf). The command is as follows:
[root@test1 mysql] # cp / usr/share/mysql/my-medium.cnf / etc/my.cnf
Mysql5.5.10 default character set modification, character encoding settings, Chinese garbled, gb2312,gbk,utf8 format to store data
By modifying the mysql default character set, you can store Chinese data to avoid Chinese garbled. The following is set to utf8 as an example.
=
The following is the result displayed on the local installation of mysql-5.5.10 without modifying the my.ini
=
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 | / usr/share/mysql/charsets/ |
+-+
8 rows in set (0.02 sec)
Mysql > show variables like 'collation%'
+-+ +
| | Variable_name | Value |
+-+ +
| | collation_connection | gbk_chinese_ci |
| | collation_database | latin1_swedish_ci |
| | collation_server | latin1_swedish_ci |
+-+ +
3 rows in set (0.00 sec)
=
Close the mysql service. Under the mysql installation directory, modify the my.ini file as follows. If not, add it directly.
=
[client]
# modify the default character encoding format of the client to utf8
Default-character-set=utf8
[mysqld]
# modify the default character encoding format on server to utf8
Character-set-server = utf8
=
After modification, enter the command again to view it, and the result is as follows
=
Mysql > show variables like 'character%'
+-+
| | Variable_name | Value |
+-+
| | character_set_client | utf8 |
| | character_set_connection | utf8 |
| | character_set_database | utf8 |
| | character_set_filesystem | binary |
| | character_set_results | utf8 |
| | character_set_server | utf8 |
| | character_set_system | utf8 |
| | character_sets_dir | / usr/share/mysql/charsets/ |
+-+
8 rows in set (0.00 sec)
Mysql > show variables like 'collation%'
+-+ +
| | Variable_name | Value |
+-+ +
| | collation_connection | utf8_general_ci |
| | collation_database | utf8_general_ci |
| | collation_server | utf8_general_ci |
+-+ +
3 rows in set (0.00 sec)
=
Check all the character sets that mysql has installed, that is, the character sets that can be used in mysql, and the results are 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 |
| | 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 |
+-- +
39 rows in set (0.00 sec)
=
After all the above settings, all character sets in mysql are utf8, but garbled Chinese characters will still appear during console operation.
This is because the windows XP console window displays the character encoding format gbk by default, so here you want to set the character encoding format used to display the results to utf8.
Every time you perform an operation on the console, you must make the following settings so that the results can be displayed in Chinese normally.
=
Mysql > set character_set_results='gbk'
Query OK, 0 rows affected (0.00 sec)
=
In general, even if you set the default character set of the table to utf8 and send the query through UTF-8 encoding, you will find that the code stored in the database is still garbled.
The problem lies in this connection connection layer. The solution is to execute the following sentence before sending the query:
=
Mysql > set names gbk
Query OK, 0 rows affected (0.00 sec)
It is equivalent to the following three instructions:
SET character_set_client = utf8
SET character_set_results = utf8
SET character_set_connection = utf8
Therefore, this method can also solve the problem that all character encodings are set to utf8 and the console displays Chinese garbled codes.
On how to modify the default character set of mysql5.5.10 in windows and character encoding settings to share here, I hope the above content can be of some help to you, you can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.