The solution of Chinese garbled Code in mysql Table
This article is to share with you about the solution to Chinese garbled code in mysql table. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
We can first check our mysql database to see if the Chinese is garbled.
Log in to the database, and then in the test database, create a table, then insert it into Chinese, and query the results. We can see that Chinese has become a question mark.
Show databases
Use test
Create table users (name varchar (50))
Insert into users values ('Zhang San')
Select * from users
Let's find out what the value of each character-related variable is.
Enter SHOW VARIABLES LIKE 'character%'
We can see that the value of character_set_database is latin1. Everyone's value may not be the same as mine, generally speaking, it should not all be utf8.
If there are multiple places that are not utf8, we need to modify the configuration file my.ini of mysql.
It is usually located in the root directory of the installation path, or under the bin of the root directory of the installation path, or under Linux / etc/my.cnf.
In my.ini:
Search for [client], modify or add default-character-set=utf8
Search for [mysqld], modify or add character-set-server=utf8
Found [mysql], modify or add default-character-set=utf8
Restart the mysql database.
You can run services.msc under Windows, find the mysql service, and restart
Under Linux, you can / etc/init.d/mysqld restart
Mine is xampp, did not add services, just click stop, and then start.
View the values of each variable
SHOW VARIABLES LIKE 'character%'
Or
Status
Test whether the code is still garbled after modification.
Create database baidujingyan
Use baidujingyan
Create table users (name varchar (50))
Insert into users values ('Zhang San')
Select * from users
You can see that our database has been able to display Chinese normally.
Thank you for reading! On the mysql table Chinese garbled solutions to share here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.