In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to solve the problem of Chinese garbled code or Chinese data insertion failure in MySQL command window". In daily operation, it is believed that many people have doubts about how to solve the problem of Chinese garbled code or Chinese data insertion failure in MySQL command window. The editor consulted all kinds of materials and sorted out simple and useful operation methods. I hope it will be helpful for you to answer the question of "how to solve the problem of Chinese garbled code or failure to insert Chinese data in MySQL command window"! Next, please follow the editor to study!
When using the command window to operate the MySQL database on Windwos, Chinese garbled will occur if the character encoding of the command window is not consistent with that of the database.
For example, Chinese garbled will appear in a query, or an error will occur when inserting data: "ERROR 1366 (HY000): Incorrect string value:'\ xD5\ xC5\ xC8\ xFD' for column 'name' at row 1"
Mysql > insert into user (name,gender,age) values (Zhang San, male, 22); ERROR 1366 (HY000): Incorrect string value:'\ xD5\ xC5\ xC8\ xFD' for column 'name' at row 1mysql > select * from user +-+ | id | name | gender | age | updated_time | + -+ | 1 | zhangsan | M | 22 | 0-10-31 17:03:25 | | 2 | Laos | Laos | 22 | 2018-11-01 09:01:43 | +-+ 2 rows in set (2018 sec)
At this time, you can first check the environment coding configuration. Mine is utf8, and the result is as follows.
Mysql > show variables like 'char%' +-- +-- + | 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 | C:\ Program Files\ MySQL\ MySQL Server 5.5\ share\ charsets\ | +- -+-+ 8 rows in set (0.00 sec)
Viewing the properties of the windwos command window shows that the encoding format is GBK and cannot be changed.
At this point, we can use "set names gbk;" to specify the encoding format when the client sends the mysql statement, and we can see that the encoding format of the three variables client, connection, and results has changed to gbk, and the others have not changed.
Mysql > set names gbk;Query OK, 0 rows affected (0.00 sec) mysql > show variables like 'char%' +-- +-- + | Variable_name | Value | | +-- +-- + | character_set_client | gbk | | | character_set_connection | gbk | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | gbk | | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | C:\ Program Files\ MySQL\ MySQL Server 5.5\ share\ charsets\ | + -+-+ 8 rows in set (0.00 sec)
It is no problem to perform the insert operation again, and the query data will not be garbled in Chinese.
Mysql > insert into user (name,gender,age) values ('Zhang San', 'male', 22); Query OK, 1 row affected (0.04 sec) mysql > select * from user +-+ | id | name | gender | age | updated_time | + -+ | 1 | zhangsan | M | 22 | 0-10-31 17:03:25 | | 2 | Zhang San | male | 22 | 2018-11-01 09:01:43 | +-+ 2 rows in set (2018 sec) so far The study on "how to solve the problem of Chinese garbled code or failure of inserting Chinese data in MySQL command window" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.