1. Add the existing fields in the table constraints AUTO_INCREMENT modifier
mysql> alter table user modify uid int auto_increment primary key;
ERROR 1062 (23000): ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY'
Understand: uid 0, 1 and auto_increment is from the beginning, so the modification failed.
After the 0 uid into zero field, and then modify it is added:
mysql>UPDATE USER SET uid=2 WHERE uid=0;
mysql>alter table user modify uid int auto_increment;
success!
2. Delete the field in the table constraints existing in AUTO_INCREMENT modifier
mysql>alter table user modify uid int;
If there is another constraint to the table, such as primary key, there is still need to delete a constraint:
mysql>alter table user drop primary key;
Note: If the primary key and auto_increment exist, you must first delete auto_increment, you can remove the primary key.