title: What happens when autoincrement clashes with existing data in MySQL?
body: <p>I have a MySQL table with an autoincremented id column. The id started from 1 and is now in the 4000s.</p>
  
  <p>However, I also need to port some legacy data into this table from an old version of the application. The ids of this data start from 5000 and must be preserved for auditing purposes.</p>
  
  <p>What happens if I insert an entry after my autoincrement counter is up to 4999? Is autoincrement smart enough to look for the next available id, or will it crash because it tries to insert id 5000, which already exists?</p>
  
  <p>While advice on how to work around this problem is very helpful, I'd also like to understand what MySQL would do in this situation and if I need to intervene at all.</p>