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 that mysql can't store Chinese string

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Xiaobian to share with you mysql storage can not be Chinese string solution, I believe most people do not know how, so share this article for your reference, I hope you read this article after a great harvest, let us go to understand it together!

mysql can not store the Chinese string solution: first change the database and table character set to utf8; then delete the relevant fields and re-create; finally use SQL statement to modify the character set to utf8.

These days, when installing MySQL-Cluster service, I found that there was an error in saving Chinese characters when operating the database after installation. Navicat reported an error as shown in the figure:

Detection found that MySQL does not set the default character set, the default character set is latin1, it does not support Chinese characters, then our solution is very clear, is to change the character set.

Let's change the character set of the database first

We change the character set of the table again:

Up to this point, I still report errors when saving data. I check the data again and find that there are character sets in the fields.

show full columns from bd_user;

We delete this field and recreate it, and the character set will be fine.

Of course, we can also modify character sets with SQL statements:

alter database test default character set = utf8; // test is database name alter table test.bd_user default character set = utf8; // bd_user is table name alter table test.bd_user modify column user_name varchar(20) character set utf8 collate utf8_general_ci; //the field type will also be changed here. The above is mysql, which cannot store all the contents of the solution to the Chinese string. Thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

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