How to set the mysql auto-increment value

Source: Internet
Author: User
How to set the mysql auto-increment value has a mysql table structure: CREATETABLEIFNOTEXISTS 'dizeng' (& nbsp; 'id' int (11) NOTNULLAUTO_INCREMENT, & nbsp; 'Reid 'int (11) DEFAULTNULL, & nbsp; 'name' varchar (255) DE
There is a mysql table structure as follows:
Create table if not exists 'dizeng '(
'Id' int (11) not null AUTO_INCREMENT,
'Reid 'int (11) default null,
'Name' varchar (255) default null,
'Idshow' tinyint (4) not null default '1 ',
Primary key ('id ')
) ENGINE = MyISAM default charset = utf8 AUTO_INCREMENT = 1;
Insert data in local debugging:
Insert into dizeng (reid, name) values (0, 'XXX'); in this way, 10 data records are inserted cyclically. However, the field IDs are arranged as follows:
2, 4, 6, 8, 10, 12... the incremental value is 2.

Similarly, I take the dizeng table to another machine. The field di is a normal incremental value of 1, and the id sorting is:
1, 2, 3, 4, 5, 6 ....

I don't know why. how can I restore the mysql incremental value on my local end to normal? 1. Thank you!

------ Solution --------------------
Try again after deletion
------ Solution --------------------
First run SET @ auto_increment_increment = 1;

Or write the configuration file auto_increment_increment = 1 and restart

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.