WordPress log in redirect loop

I recently ran into an issue with redirect loop when logging into a new WordPress site. Enter username & password, click login – get redirected back to log in page.

First thing I did was search Google, of course, for WordPress wp-login redirect loop. Suggestions of resetting browser cache and the like didn’t help, so I checked the error logs and found this:

WordPress database error Duplicate entry '0' for key 'PRIMARY' for query INSERT INTO `wp_usermeta`

Turns out the issue was a few of the WordPress tables somehow didn’t get set to AUTO_INCREMENT. Figuring out which ones was a matter of checking a correct database and mimicking that.

The two for me were wp_users and wp_usermeta. Here’s how I fixed it using PHPMyAdmin:

  1. Open the Database with PHPMyAdmin and click on the wp_users table
  2. Check if AUTO_INCREMENT is set to the ID column in Extra. If it is, then this post probably won’t help you:

yes-auto_increment

Otherwise it will look like this:

no-auto_increment

  1. Click Edit/Change. You’ll see something like the image below. Check the A_I box and save.

auto-increment-checkbox

  1. Check the rest of the tables for similar issues. Use a good database as reference. I had issues with wp_usermeta and wp_term_taxonomy

As a side note, this particular install was migrated from a Joomla install with a really ugly database. Possibly related.

Leave a Reply

Your email address will not be published. Required fields are marked *

Tell us about your project.

We'd love to hear what you're working on.

Work with us

Hi. We are Spigot. Telemarketers pronounce it Spy-got.

We are a Park City, Utah based web design shop that excels at building custom websites powered by WordPress and WooCommerce. We love content - content strategy, content curation, content soup...????Have a look around the site. As you browse you'll find useful navigation links in the sidebar on the left. We hope you find them useful anyway... Please let us know what you think, shoot us a message here.