How to make InnoDB table not reset auto-increment when server restarts?

I have MySQL 5.5.37 running on my development machine. I use innodb tables. The following problem was encountered - auto-increment is reset after the server is restarted.

Found autoinc_lock_mode , set to 0, but did not help.

Team

SHOW VARIABLES shows a value of 0 for autoinc_lock_mode.

What am I doing:

select max(id) from tablex; // 11, autoincrement is 12
insert into tablex values ('foo');
select max(id) from tablex; // 12, autoincrement is 13
delete from tablex where id > 11; // autoincrement is 13

Then I restart the server ... and .... (drum roll)

show create table tablex; // autoincrement 12 instead of 13

WHAT TO DO WRONG ?: (

// UPD

I need to use the MyISAM table. Thank you all for your answers / comments.

+4
source share
1 answer

InnoDB reset .

InnoDB counter t, AUTO_INCREMENT ai_col: , t, InnoDB :

SELECT MAX(ai_col) FROM t FOR UPDATE

; InnoDB auto-increment . . auto_increment_increment.

, InnoDB 1. auto_increment_offset.

, :

AUTO_INCREMENT InnoDB, InnoDB , , . , .

, , , .

, , (, MyISAM Archive) reset .

+8

Source: https://habr.com/ru/post/1545829/


All Articles