Home >Operation and Maintenance >Linux Operation and Maintenance >How to solve the 1366 error of mysql in Linux
Solution: 1. Use "vim /etc/my.cnf" to edit the "my.cnf" file of mysql, and add "default-character-set=utf8" under "mysqld"; 2. Use "service mysqld restart" to restart mysql; 3. Use "SHOW VARIABLES LIKE 'character%'" to check whether the file has been changed.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
1366,Incorrect string value: '\xE8\xA5\xBF\xE6\x96\xBD…' for column 'name'
The reason for the error is that the database cannot recognize Chinese and needs to configure the encoding
Solution:
1. Check the mysql encoding: SHOW VARIABLES LIKE 'character %';
Edit the my.cnf file of mysql (my.cnf is usually in the /etc/ directory)
vim /etc/my.cnf
Add it under [mysqld] default-character-set=utf8
2. Restart mysql
service mysqld restart
3. Check mysql encoding: SHOW VARIABLES LIKE 'character%';
Even if the above operation is done to save Chinese characters into the table, it still doesn’t work, then modify the database encoding
ALTER DATABASE 数据库名 DEFAULT CHARACTER SET utf8;
Recommended learning: Linux video tutorial
The above is the detailed content of How to solve the 1366 error of mysql in Linux. For more information, please follow other related articles on the PHP Chinese website!