Home > Database > Mysql Tutorial > body text

What should I do if a 1062 error occurs in mysql?

coldplay.xixi
Release: 2020-08-24 15:39:27
Original
14634 people have browsed it

The solution to the 1062 error in mysql: first open the mysql configuration file [my.cnf]; then add the relevant code under client and mysqld; finally save and close and restart mysql.

What should I do if a 1062 error occurs in mysql?

The solution to the 1062 error in mysql:

The versions of the two instances are close. It is guessed that it is not a version problem. The two DBs that execute SQL statements are imported in the same way, so I suspect it is a character set problem in the database.

Check the character set configuration of mysql:

show variables like 'collation_%';
show variables like 'character_set_%';
Copy after login

The result is utf-8 running normally, and the error reported is latin1, as shown below.

An example of mysql ERROR 1062 error cause and solution

What should I do if a 1062 error occurs in mysql?

So modify the mysql character set configuration.

1. Open the mysql configuration file my.cnf

2. Add a line below [client]:

default-character-set=utf8
Copy after login
Copy after login

3. In [ mysqld] Also add below:

default-character-set=utf8
Copy after login
Copy after login

4. Save and close and then restart mysql: service mysql restart

Check the character set of mysql again, it should be utf8.

If the mysql version is 5.5.x and the OS is ubuntu12.04, the mysql service may not be started after the above configuration. At this time, replace the changes to [mysqld] in step 3 with:

3. Add:

character-set-server=utf8
Copy after login

under [mysqld] and then restart.

Related learning recommendations: mysql tutorial

The above is the detailed content of What should I do if a 1062 error occurs 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