MySQL Table Not Auto Incrementing Past 127

April 12th, 2010 - Posted by Steve Marks to MySQL, Web Development.

When inserting records into a MySQL table that contains an auto-incrementing field you might at some point start receiving the following error:

“Duplicate entry ‘127’ for key 1”

If this is the case it means the datatype of the field in question is set as ‘tinyint’. The tinyint datatype only accepts integers up to 127 (or 255 if set as unsigned) and therefore on the 128th insertion attempt you will receive the above error.

To get around this issue, try changing the datatype of this field to a type that supports larger numbers such as a smallint, mediumint or int.

This entry was posted on Monday, April 12th, 2010 at 9:04 pm by +Steve Marks and is filed under MySQL, Web Development. You can follow any responses to this entry through the RSS 2.0 feed.
Comments (0)
Comments are closed.