Home > Database > Mysql Tutorial > body text

How to solve the problem when ERROR 1366 appears in mysql?

零下一度
Release: 2017-05-02 09:46:52
Original
4605 people have browsed it

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 -p
Copy after login

Enter the password Finally, enter the following line of code to display the encoding currently used by mysql:


SHOW VARIABLES LIKE 'character%';
Copy after login

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=utf8
Copy after login

Save and exit.

Restart the mysql service


service mysql restart
Copy after login

Now 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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!