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 solution to the non-display of Chinese in mysql

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

Share

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

This article will explain in detail the solutions that can not be displayed in Chinese in mysql. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Solutions that cannot be displayed in Chinese in mysql: 1. Find the configuration file [my.ini] of mysql, find [default-character-set], change the parameters to gbk;2, view the structure of the table, and change the character set of username in the user table.

Solutions to the inability to display Chinese in mysql:

1. Because gb2312 is used by default in windows operating system, and latin1 is used by both client and server when mysql is installed, this leads to a problem of mismatch between character set and character verification. At this time, you only need to find mysql's configuration file my.ini, find default-character-set, and change his parameter to gbk. There are two such parameters, one for the customer. One belongs to the server.

2. For the previous database, the path is specified by the datadir in my.ini. There is a special folder under the data folder, that is, the database. Below, there is a db.opt file whose content is changed from default-character-set=latin1 default-collation=latin1_swedish_ci to default-character-set=gbk defaultcollation=gbk_chinese_ci, and you can restart the service. The encoding of tables created later will change. Can display Chinese.

3. The Chinese solution cannot be inserted because of the field coding of the table:

View the structure of the table:

Mysql > show create table users

Change the character set of the username of the users table. Because there is already data in the table, changing the username character set requires emptying the data in the users table first.

Mysql > truncate table users

Change the character set of username in the user table

Mysql > alter table users modify username char (20) character set gbk

At this time, Chinese characters are inserted again, and the insertion is successful.

Mysql > insert into users values (88Jing 'Chinese')

4. Error occurred in mysql Can't create table "Table name" (errno: 121)

The data file still exists, so rebuilding a data file with the same name will cause an error. The solution is to delete the current database first, and then rebuild the database and table. Drop database xxxxcreate database xxx should be deleted before setting up the database.

So much for the solution that Chinese can not be displayed in mysql. I hope the above content can be helpful to you and 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.

Share To

Database

Wechat

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

12
Report