Home >Operation and Maintenance >Linux Operation and Maintenance >How to solve the 1366 error of mysql in Linux

How to solve the 1366 error of mysql in Linux

WBOY
WBOYOriginal
2022-07-14 16:11:333043browse

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.

How to solve the 1366 error of mysql in Linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How to solve the 1366 error in mysql in Linux

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 %';

How to solve the 1366 error of mysql in Linux

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

How to solve the 1366 error of mysql in Linux

2. Restart mysql

service mysqld restart

3. Check mysql encoding: SHOW VARIABLES LIKE 'character%';

How to solve the 1366 error of mysql in Linux

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What is .a file in linuxNext article:What is .a file in linux