如何修改mysql主键自动增长的起始值
怪我咯
怪我咯 2017-04-17 13:37:47
0
3
701

自增长跟PHP索引数组的下标一样,会根据当前最大的那个值加1。

为什么系统能够从1开始进行自动增长?而为什么每次又是自动增加1?
系统是通过系统里面的配置文件来识别。
show variables like ‘auto_increment%’;

那么我如何修改这两项呢?????

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(3)
伊谢尔伦
CREATE TABLE `xxx` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
)AUTO_INCREMENT=4;
伊谢尔伦

It is not recommended to modify the system settings. If you need to modify the auto-increment starting value of a certain table, you can use:

alter table table_name auto_increment = 9999;
伊谢尔伦

As Ewellyuan said, it is best not to modify system properties, but only modify table properties. If you really want to change it, you can modify it through the following command:
mysql> set [global] auto_increment_increment=X;
where global refers to the global modification. Without global, it is just the session level (for the current user connection, if you exit The modification will be invalid)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template