Search code examples
mysqlauto-increment

MySQL problem: autoID not starting with 1


I'm creating a new table from scratch through scripting - first, I'm dropping it (in case it already exists):

DROP TABLE IF EXISTS `myTable`

then I'm creating it:

CREATE TABLE IF NOT EXISTS `myTable` (
`id` int(11) NOT NULL AUTO_INCREMENT,
... and so on

The problem: for some strange reason, my autoID-field ALWAYS starts at 2028 instead of 1, although I'm generating it from scratch. What is wrong?


Solution

  • Look at the end of create block. You probably have something like AUTO_INCREMENT=2028. If this is the case just put AUTO_INCREMENT=1 at the end of create table block

    such as

    CREATE TABLE IF NOT EXISTS `myTable` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    ...
    ) ENGINE=xxx AUTO_INCREMENT=1;