Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The cause and solution of garbled Code in Mysql Database

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the causes and solutions of garbled code in Mysql database. In daily operation, I believe that many people have doubts about the causes and solutions of garbled code in Mysql database. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about the cause and solution of garbled code in Mysql database. Next, please follow the editor to study!

Today, it's time for the Mysql garbled problem. In the past, it was always solved in a hurry. I can't stand it this time. It's changed in a daze every time. This time I decided to explore and understand it after reading a lot of materials and blogs. Write it down. If anything is wrong, please correct it. 1. First of all, Mysql only supports multiple character sets after 4. 0. So this kind of problem will not occur until after 4.0. The rule of transcoding is to convert the encoding from "client-side encoding" to "server-side encoding" when entering data and from "server-side encoding" to "client-side encoding" on output. The character set processing of MySQL is as follows: 1. Send a request. 1) the client sends a request to the server. 2) the server will transfer the requested data from the client character set (character_set_client) to the server connection character set (character_set_connection). 3) the server then detects the character set of the storage area (table,column), and then changes the data from the connection character set (character_set_connection) to the character set of the storage area (table,column), and then stores or queries. 2. Return the request. 1) the server converts the character set of the storage area (table,column) into the server connection character set (character_set_connection). 2) convert the server connection character set (character_set_connection) to the resulting character set (character_set_results), and then send it to the client. First, let's take a look at mysql > status;. We can see the settings for the four character sets. 1. Changing the encoding in the my.ini file can change all character sets. 2.set names "uf8" can change the two character sets of Client conn. 3. The setting encoding when setting up the database can change the DB. I see, after the principle, I began to solve the problems I encountered today. 1. Chinese is displayed normally in other places. However, the garbled code cannot be displayed in CMD. First of all, I set my.ini to set all the character sets to utf8. Personally, I feel that utf8 tends to be standard. Then set it to utf8 when the database is established. But see CMD query is garbled. This is because of CMD. That is, what we are familiar with is that it does not support utf8. So I set the output to client-side encoding and convert it to GBK. Also known as set names gbk. Ok problem resolved. At this point, on the "Mysql database garbled reasons and solutions" on the end of the study, 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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report