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.
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_%';
The result is utf-8 running normally, and the error reported is latin1, as shown below.
An example of mysql
So modify the mysql character set configuration.
1. Open the mysql configuration filemy.cnf
2. Add a line below [client]:
default-character-set=utf8
3. In [ mysqld] Also add below:
default-character-set=utf8
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
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!