修改Mysql步长及偏移量

2022-07-07 09:48:54

可以修改系统变量 auto_increment_increment

查看步长信息

mysql> SHOW VARIABLES LIKE 'auto_inc%'; 
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| auto_increment_increment | 1     |
| auto_increment_offset    | 1     |
+--------------------------+-------+
2 rows in set (0.01 sec)

修改步长信息

mysql> SET @@auto_increment_increment=10;  //设置步长
Query OK, 0 rows affected (0.00 sec)

mysql> SET @@auto_increment_offset=10000;  //设置步长
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW VARIABLES LIKE 'auto_inc%'; 
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| auto_increment_increment | 10     |
| auto_increment_offset    | 10000     |
+--------------------------+-------+
2 rows in set (0.01 sec)

修改 my.conf

vi /etc/my.cnf
auto_increment_increment=10;
auto_increment_offset =10000;

重启mysql即可

  • 作者:Webben
  • 原文链接:https://blog.csdn.net/Webben/article/details/103602483
    更新时间:2022-07-07 09:48:54