This article mainly introduces how to solve the problem of inserting Chinese characters into error under centOS7. It has certain reference value. Interested friends can refer to it. After I just installed mysql, I created the database abc, and then created a new abc table. There is no problem inserting English, but there is a problem inserting Chinese, and an error will be reported:
ERROR 1366 (HY000) : Incorrect
stringvalue: '\xE4\xBD\x99\xE9\x93\xB6...' It should be a database encoding problem, so the database encoding should be changed
There are 2 methods here. One is to directly type the code settings, and the other is to modify the file /usr/my.cnf in CentOS7,
The first method: List the encoding table of the database
mysql> show variables like '%char%';
Modify the encoding format:
mysql> set character_set_database=utf8; mysql> set character_set_server=utf8;
etc.
is to retain the original character_set_filesystem and character_sets_dir The default value remains unchanged, just change everything else to utf8
Then delete the originally created database
Create a new one, create a table, and you can insert Chinese. . . Second method: Modify the file /usr/my.cnf in CentOS7,Open the configuration file:
vi /etc/my.cnf;Add the following content under [mysqld], [mysql], [client] respectively[mysqld] character_set_server = utf8 [mysql] default-character-set=utf8 [client] default-character-set=utf8Remarks: Shortcut keys for editing files: Enter
edit mode
Edit##Exit Edit ModeThe above is the detailed content of Detailed explanation of the solution to the error when inserting Chinese characters into mysql under centOS7 (picture). For more information, please follow other related articles on the PHP Chinese website!