The self-increment queried in the information_ schema table is inconsistent with the actual self-increment of the table.

Database is mysql8

the self-increment id checked out by the following statement and the actual self-increment id of the table will not,

select auto_increment from information_schema.tables where table_schema="test" and table_name="product";

the engine of the table is MyISAM
try to fix

alter table product auto_increment=23;
The

modification has no effect
repair, and the optimized table cannot solve the problem.
the same is true of changing the engine of the table to innodb. After analyzing the table, the self-increasing information in the information_ schema.tables table can return to normal

.
Dec.07,2021

mysql8 has some changes in auto_increment from previous versions.
first of all, the auto_increment column of information_schema.tables is recorded immediately after the, alter table xx auto_increment=n, command is executed, but the information_ schema.tables table is the memory engine, so the role of, alter table will be rolled back after restart. For example, if the current auto_increment is 30 and alter table is used to modify auto_increment to 50, and then restart MySQL, then auto_increment will fall back to 30, so why can tables fall back to 30 after restart, since tables is a memory table? That's because MySQL is queried through select max ();
after the command, alter table xx auto_increment=n, is executed in MySQL8, it is first recorded that redo, will also display the value in the auto_increment column of information_schema.tables if certain conditions are met. Under what conditions? If you take a look, you can see that information_schema.tables is no longer a memory table, but a view (view). If you look at the creation DDL, of this view, you can see that the auto_increment column is referenced from the auto_increment column of the mysql.table_stats table, and the mysql.table_stats table is related to statistics, so it is natural that the auto_increment column of information_schema.tables will be updated only when analyze table updates the statistics.


the table_name in your select statement is product, but the table_name in your alter statement is test, and test is your database name.
you should:

alter table product auto_increment=23;
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb6e52-5d42b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb6e52-5d42b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?