Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql Failed to read auto-increment value from storage engine

I am having mysql table with one id field as auto-increment .

When I insert values to the table am getting error as

1467 - Failed to read auto-increment value from storage engine

Also the show table status shows me that the field with auto increment has

18446744073709551615 as Auto_increment value.

What would be the issue can any one help me ....?

like image 374
ashu Avatar asked Sep 08 '11 10:09

ashu


People also ask

Why is my auto increment not working in MySQL?

Basically this is a bug in MySQL that causes the problem but a work around is simple. The problem happens when the Auto-Increment value of a table grows beyond the limit. Just run this SQL query in MySQL to fix the bug. Table_name is the name of the table where you found the error while inserting data into.

Can we insert auto increment value in MySQL?

Syntax for MySQL MySQL uses the AUTO_INCREMENT keyword to perform an auto-increment feature. By default, the starting value for AUTO_INCREMENT is 1, and it will increment by 1 for each new record. VALUES ('Lars','Monsen'); The SQL statement above would insert a new record into the "Persons" table.

What happens if MySQL auto increment reaches limit?

What will happen if the MySQL AUTO_INCREMENT column reaches the upper limit of the data type? When the AUTO_INCREMENT column reaches the upper limit of data type then the subsequent effort to generate the sequence number fails.

What is auto increment in MySQL?

Auto-increment allows a unique number to be generated automatically when a new record is inserted into a table. Often this is the primary key field that we would like to be created automatically every time a new record is inserted.


9 Answers

I had the same error but in my case I had about 1.5k records in the table. I fixed it by resetting the AUTO INCREMEN like that:

ALTER TABLE `table_name`  AUTO_INCREMENT = 1
like image 193
Alex Rashkov Avatar answered Oct 05 '22 00:10

Alex Rashkov


Problem could absolutely be that: convert 18446744073709551615 to hex and you'll find
$FFFF-FFFF-FFFF-FFFF.
If your field is an unsigned 64bit you reach its limit.

like image 39
Marco Avatar answered Oct 04 '22 22:10

Marco


I started getting this error a couple of weeks back when running insert statements:

Duplicate entry '127' for key 'PRIMARY'

... even though my table was set to auto increment. I went in and changed the auto_increment value from 127 to 128 then I started getting this error:

1467 - Failed to read auto-increment value from storage engine

I eventually figured out that the table had been initially created with tinyint columns for the ID not standard ints ... so basically it couldn't comprehend numbers bigger than 127. I switched the column type to proper integers and that solved the issue.

Hope that helps someone :)

like image 33
Mike Avatar answered Oct 04 '22 23:10

Mike


For my part, I made a dumb mistake. I had earlier altered my table and changed the name of the AUTO_INCREMENT column from ID to id. So, given column names are case-sensitive, subsequent inserts couldn't find the original column.

like image 40
Cedric Ipkiss Avatar answered Oct 04 '22 22:10

Cedric Ipkiss


Actually, you can simply alter the column to delete its auto_increament property and set it as auto_increment again. On my side, this way did work.

like image 26
Shinbo Avatar answered Oct 05 '22 00:10

Shinbo


I go the same error. I just alter the table and increase the size of my auto increment field and then run the following query -

ALTER TABLE `table_name`  AUTO_INCREMENT = 6221;

where 6221 is the last value of the filed with Auto_increment.

like image 36
Deepak Sharma Avatar answered Oct 05 '22 00:10

Deepak Sharma


I experienced this error for the first time less than an hour ago. Resetting the auto_increment using a SQL statement in PHP MyAdmin failed. After looking for a solution I dropped the table and created a replacement. The error remained. Looking closer revealed the auto_increment was set to 0 even though I had specifically set the primary_key and auto_increment while creating the fields. Manually resetting auto_increment to 1, again using PHP MyAdmin, eliminated the error. Luckily for me I was only working with a 3-column table containing a few rows of test data.

like image 37
Robert Avatar answered Oct 04 '22 23:10

Robert


I fixed it by removing the auto increment , saving table and then add auto increment again.

like image 20
JakesIV Avatar answered Oct 05 '22 00:10

JakesIV


I had this problem today, too. I have a table with over two million rows and tried to add another 140K rows with LOAD DATA when this error occurred. I switched to the MyISAM engine and it all worked.

like image 32
Christian Lundahl Avatar answered Oct 05 '22 00:10

Christian Lundahl