Home  >  Article  >  Backend Development  >  怎么设置mysql自动递增的数值

怎么设置mysql自动递增的数值

WBOY
WBOYOriginal
2016-06-13 13:12:081157browse

如何设置mysql自动递增的数值
有一个mysql表结构如下:
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 into dizeng (reid,name)values(0,'xxx');这样循环插入10条数据。但是字段id的排列却是:
2,4,6,8,10,12...这种的递增值为2的情况。

同样的我把dizeng表拿到其他机器上操作。字段di是正常的递增值1,id排序为:
1,2,3,4,5,6....

不知道这个到底是什么原因,该如何把我本地端的mysql递增值恢复正常情况的1。谢谢!

------解决方案--------------------
删除后新建一遍试试
------解决方案--------------------
先执行SET @auto_increment_increment=1;

或配置文件写入auto_increment_increment=1,重启

Statement:
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