Home >Database >Mysql Tutorial >What should I do if the Chinese in mysql cannot be displayed?
Solution to the problem that Chinese characters in mysql cannot be displayed: 1. Find the mysql configuration file [my.ini], find [default-character-set], and change the parameters to gbk; 2. Check the structure of the table , change the character set of username in the user table.
##More related free learning recommendations: mysql tutorial(Video)
Solution to the problem that Chinese cannot be displayed in mysql:
1. Because the windows operating system uses gb2312 by default This character, when mysql is installed, both the client and the server use latin1 by default, so this leads to a problem of character set and character verification mismatch. At this time, you only need to find the mysql configuration file my.iniFind
default-character-set and just change its parameters to gbk. There are two such parameters, one for the client and one for the server.
default-character- set=latin1 default-collation=latin1_swedish_ci Change to
default-character-set=gbk defaultcollation=gbk_chinese_ci and restart the service. The encoding method of tables created later will change. Can display Chinese.
mysql> show create table users;Change the character set of username in the users table. Because there is already data in the table, the operation of changing the username character set must first clear the data in the users table
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;Then insert Chinese characters , the insertion is successful.
mysql> insert into users values(88,'中文');4. An error occurred in mysql Can't create table "table name" (errno: 121)The data file still exists, so if you create a data file with the same name, an error will occur. The solution is: delete the current database first, and then re-create the database and tables. You should delete it first and then create the database drop database xxxxcreate database xxxx
The above is the detailed content of What should I do if the Chinese in mysql cannot be displayed?. For more information, please follow other related articles on the PHP Chinese website!