Solve the problem related to mysql inserting Chinese Characters in centos 7
After mysql is installed, the database abc is created, and a new abc table is created. There is no problem in English language insertion, but there is a problem in Chinese language insertion, and an error will be reported:
ERROR 1366 (HY000): Incorrect string value: '\ xE4 \ xBD \ x99 \ xE9 \ x93 \ xb6 ...'
It should be a database encoding problem, so we should change the database encoding.
Here is the method in 2. One is to directly knock on the Code settings, the other is to modify the file/usr/my. cnf in CentOS7,
Method 1:
List database encoding tables
Mysql> show variables like '% char % ';
Modify the encoding format:
Mysql> set character_set_database = utf8;
Mysql> set character_set_server = utf8;
And so on
That is, keep the original default values of character_set_filesystem and character_sets_dir unchanged, and change all other values to utf8.
Then, delete the original database and create a new table. Then, you can insert Chinese characters into the table...
Method 2: Modify the file/usr/my. cnf in CentOS7,
Open the configuration file:
Vi/etc/my. cnf;
Add the following content under [mysqld], [mysql], and [client ]:
[Mysqld]
Character_set_server = utf8
[Mysql]
Default-character-set = utf8
[Client]
Default-character-set = utf8
Note:
Shortcut keys used to edit files:
Enter edit mode
I
Exit edit mode
Esc
Exit the file and save it.
: Wq