Home >Database >Mysql Tutorial >What should I do if mysql cannot store Chinese strings?
The solution to the problem that mysql cannot store Chinese strings: first change the character set of the database and table to utf8; then delete the relevant fields and recreate them; finally use SQL statements to modify the character set to utf8.
Recommended: "mysql video tutorial"
I have been installing the MySQL-Cluster cluster service these days and found that the installation Afterwards, an error occurred when saving Chinese characters when operating the database. Navicat reported an error as shown in the figure:
The detection found that when MySQL did not set the default character set, the default character set was latin1, which did not Supporting Chinese characters, then our solution is very clear, which is to change the character set.
We first change the character set of the database
We then change the character set of the table:
At this point, I still get an error when saving the data. I checked the information again and found that the field also has a character set
show full columns from bd_user;
After deleting this field and re-creating it, the character set will be fine
Of course, we can also use SQL statements to modify the character set:
alter database test default character set = utf8; // test为数据库名 alter table test.bd_user default character set = utf8; // bd_user为表名 alter table test.bd_user modify column user_name varchar(20) character set utf8 collate utf8_general_ci; // 这里也会改变字段类型
The above is the detailed content of What should I do if mysql cannot store Chinese strings?. For more information, please follow other related articles on the PHP Chinese website!