More fixes

WordPress keeps asking for a "Database Update" that never sticks

After an update, WordPress shows "Database Update Required". You click Update WordPress Database, it says Update Complete, you click Continue, and the same screen is back. You cannot reach the dashboard at all. The visitors' side of the site usually still works, which is why this can go unnoticed until someone needs to edit a page. Below is a rebuilt example (not a real client), the one-minute check, and the fix for each cause.

What the owner sees at /wp-admin

What the check found


  

Why WordPress asks at all

Every WordPress release carries a database revision number in its files. The database keeps the number of the last update it ran, in the db_version setting. When you open the dashboard, WordPress compares the two. If they differ it sends you to the update screen, runs the changes, and writes the new number. A loop means that new number is either never written or never read back: WordPress keeps seeing the old one.

The one-minute check

  1. Take a backup first (database and files), from your host's panel if you cannot get into the dashboard. Everything below is safe, but a backup makes it reversible.
  2. Look for an object cache. Over FTP or the host's file manager, open wp-content. A file called object-cache.php means Redis, Memcached or a cache plugin is storing settings outside the database. This is the most common cause of the loop.
  3. Read the number in the database. In phpMyAdmin, open the wp_options table (your prefix may differ) and find db_version. Click the update button, then look again. If the number changed, the update worked and something is serving an old copy (row 1). If it did not change, the update could not write (rows 2-4).
  4. If your host gives you WP-CLI, wp core version --extra shows the revision the files expect, and wp option get db_version shows what the database holds.

What causes it and the fix

What you seeWhy it happensThe fix
"Update Complete", then the screen comes straight back. The number in the database did changeA persistent object cache (Redis, Memcached, or the host's own) still holds the old db_version and hands it to WordPress on every page loadFlush the object cache: the Redis or cache plugin's Flush button, the host panel's purge, or wp cache flush. If you cannot reach any of those, rename wp-content/object-cache.php to object-cache.php.off, load the dashboard once, then rename it back and flush
The number in the database never changes, no error shownThe database user in wp-config.php may read but not change tables (no ALTER, CREATE or INDEX rights). Common after a host move where the new user was given limited rightsIn the host's MySQL users page, give that user all privileges on the site's database, then run the update again. Your host's support can do this in a minute if the page is hidden
The update screen spins, then a blank page or 500, and it starts again next timeA large site (big shop, years of posts) runs out of time or memory before the update finishes, or the host's disk or database quota is full so nothing can be writtenRun it from the command line: wp core update-db, which has no web time limit. Check the host's disk and database usage; free space or raise the quota first. See memory exhausted if the log names memory
Started after an update that failed half way or was copied by FTPSome core files are from the new release and some from the old one, so the files keep announcing a revision the update code does not finishDownload the same WordPress version fresh from wordpress.org and upload wp-admin, wp-includes and the root files over the old ones. Never overwrite wp-content or wp-config.php. Then run the update once
Multisite: the main site is fine, but each sub-site asks for the updateEvery site in a network has its own tables and its own db_version. The network upgrade was never run, or stopped part wayAs a Super Admin, go to Network Admin > Updates > Upgrade Network and let it finish all sites. On a large network, wp core update-db --network
It appeared after restoring a backup or moving the siteThe database came from an older or newer WordPress than the files it now sits underIf the database is older, running the update once is correct. If it came from a newer WordPress, update the files to that version (or newer) instead of running the update against older files

What not to do

Flushing a cache takes a minute. Finding which cache layer holds the old number, fixing database rights at a host you did not set up, or untangling a half-finished update on a live shop is where most owners would rather have someone do it. If that is you, the box below is for that. Related: a plugin won't install or update, stuck in maintenance mode and error establishing a database connection.