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

Mysql table does not display Chinese, the solution of garbled code

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you the mysql table does not show Chinese, garbled solutions, I hope you will learn a lot after reading this article, let's discuss it together!

Mysql table does not show Chinese, garbled solutions: first check the database coding; then edit to open the my.ini file; then modify the content to "default-character-set=utf8"; finally restart the database.

The solution of Chinese garbled code in mysql data table

The data (Chinese characters) are garbled when inserting data into the mysql database:

After changing the coding of the database and data table to UTF-8, it is still garbled.

The default encoding of Mysql is Latin1, and Chinese is not supported. Therefore, if you want mysql to support Chinese, you need to change the default encoding of the database to gbk or utf8.

1. View the encoding of the database

Mysql > show variables like 'character%'

The above character settings must be consistent, but simply setting the coding format for the database and data table can not completely solve the garbled problem. I am to solve the garbled problem after setting all the above-mentioned character encoding to utf8.

Explain the above information:

| | character_set_client: the character set (encoding method) of the data requested by the client | character_set_connection: the character set received from the client and then transmitted (the encoding used to establish the connection) | character_set_database: the character set of the default database, no matter how the default database is changed. This character set is the same. | If there is no default database, use the character set specified by character_set_server, which is recommended to be managed by the system itself and not artificially defined. | | character_set_results: the character set of the result set | character_set_server: the default character set of the database server | character_set_system: this value is always utf8 and does not need to be set. It is the character set for storing system metadata. |

When the values of the above variables are inconsistent or garbled, you can modify them with the following command:

Mysql > SET character_set_client = utf8; mysql > SET character_set_results = utf8; mysql > SET character_set_connection = utf8

2. Find the edit in the MySQL5.0 installation directory and open the my.ini file, and modify it as follows:

[client] port=3306default-character-set=utf8 [mysql] default-character-set=utf8# The default character set that will be used when a new schema or table is# created and no character set is defineddefault-character-set=utf8

3. Restart the database.

After reading this article, I believe you have a certain understanding of the mysql table does not show Chinese, garbled solutions, want to know more related knowledge, welcome to follow the industry information channel, thank you for reading!

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