I encountered a very strange bug in MySQL, perhaps it is something which can be fixed easily but I didn't found any solution to this problem.

When I insert a new entry in any table, via php on the website or via phpmyadmin, the DB-engine inserts the entry with a new ID, but the AUTO_INCREMENT value stays the same when I jump between "Browse" and "Operations" even after 50 times or so. BUT when I jump once between "Structure" and "Operations" I can see that the value was increased by one, but really only then. This is happening with every table in the whole MySQL Instance.

I need the auto_increment values before inserting the new entry because I am doing entries in other tables which are connected with the main table.

If screenshots needs to be provided, just ask:)

1 Answer 1


It is not safe to get the id before generating it. Instead, use LAST_INSERT_ID() after performing the INSERT.

The "unsafe" comes from two connections stumbling over each other. The function call above is multi-thread safe.

(That particular function may be spelled differently in different APIs.)

  • Okay thank you, I will look into it. But this doesnt really help that the auto_increment does not increase automatically xD
    – Sam
    May 16 at 5:28
  • Show us the INSERT that fails to increase the id. And SHOW CREATE TABLE.
    – Rick James
    May 16 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.