WordPress can’t write to DB after migration

Solution:

The problem may very well be that certain properties of the table fields (like the AUTO_INCREMENT) did not get copied over when the schema was copied.

If you are using phpMyAdmin, you can find the table in your database and then click on the Structure tab. For wp_posts, you’d probably see something like this:

 

In this case, ID is the identity column, and this table has AUTO_INCREMENT set. If that is missing from your table, click the Change button and you will see options to set it.

Unfortunately, if you have one table missing AUTO_INCREMENT, you probably have others – and if one part of the schema is missing, other important things (unique keys, indexes, etc.) might also be left out – so you should probably reevaluate your database import scripts to see if you can export the full db schema.