A few words of thanks would be greatly appreciated.


The MySQL duplicate entry 127 for key 1 error occurs when the primary key of a database or table is set to the TINYINT data or field type. A TINYINIT field type can have a maximum value of 128. When adding new records in the database, the primary key is incremented for each record added. If the size exceeds 128 for a TINYINT type primary key, the duplicate entry 127 for key 1 error will be shown. To solve the problem, the TINYINT data type of the primary key may be changed to INT or a different table command may be used to auto-increment the value of this field.

If you are using MySQL and you are facing the error "duplicate entry 127 for key 1" while trying to make an entry in your database table, do not panic. This should be linked to the following and can easily be solved as indicated below:
  • When the primary key of a table is set to TINYINT
  • The TINYINT capacity is less than 1 byte.
  • A TINYINT field can normally seize only 128 values


To solve this issue, you can choose two solutions:
  • 1. Either try to use a different table command to increase the auto-increment value of the field,
  • 2. Choose the primary key from a TINYINT to an INT type.

See also :

You can also post your problem on our Kioskea forum which you can access on the link below:
http://ccm.net/forum/forum 3 programming

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled "DUPLICATE ENTRY '127' FOR KEY 1," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).