Home >Database >Mysql Tutorial >How to solve the problem when ERROR 1366 appears in mysql?
This article mainly introduces in detail the solution to ERROR 1366 when inputting Chinese in MySQL. It has certain reference value. Interested friends can refer to it
The following error occurs when MySQL inputs Chinese:
ERROR 1366: 1366: Incorrect string value: '\xE6\xB0\xB4\xE7\x94\xB5...' for column 'introduce' at row 1
This is because of the mysql encoding problem
Open mysql
##
mysql -u root -pEnter the password Finally, enter the following line of code to display the encoding currently used by mysql:
SHOW VARIABLES LIKE 'character%';
As can be seen from the above
figure, database and server The character set uses latin1 encoding. latin1 encoding does not support Chinese, so errors will occur when storing Chinese.Solution: Modify /etc/mysql/my.cnf (this is the default installation path of mysql) After opening my.cnf, go to [mysqld] in the file Add the following lines of code:
[client] default-character-set=utf8 [mysqld] character-set-server=utf8 [mysql] default-character-set=utf8Save and exit. Restart the mysql service
service mysql restartNow delete the problematic table in mysql and rebuild it to solve the problem.
The above is the detailed content of How to solve the problem when ERROR 1366 appears in mysql?. For more information, please follow other related articles on the PHP Chinese website!