Linux · January 21, 2017 0

WordPress migration issues

Please carefully do all the steps below when migrating the wordpress to get 100% success.

Open phpmyadmin
go to wp_options table or bs_options table if you have bs_ as table prefix and check following steps

1. check siteurl and home field in option_value column and replace the old url with the new one.
2. Make sure you provide something like http://www.newsite.com/ in meta values
3. check wp-config in the old environment vs. new one for table prefix. In our case the old environment was “wp_” and the new environment’s table prefix was “wp_acctname_”. I did a search and replace and replaced ‘wp_ with ‘wp_acctname_

After importing the new database, the web site looked great from the front end, but as soon as we tried to log into WordPress we got that dreaded message.

After googling it, there were a bunch of suggestions we tried, such as:
1. check the user’s wp_capabilities and make sure they don’t have the wrong type of quotes
2. check the user’s wp_user_level
3. look for corrupt tables in the db

But none of those worked. In the end, it was an issue related to my step #3 that I didn’t do correctly. My new environment had that special table prefix, and I hadn’t done the search and replace properly.

We had a look around and found the issue, and it relates to the various places the table prefix shows up in the database.

THE DATABASE TABLE PREFIX IS NOT JUST USED IN THE DATABASE TABLE NAMES. IT’S ALSO USED IN DATA!

If that data isn’t also changed, a permission error happens because the returned values will be empty.

Specifically, these changes fixed the issue:

In the table: wp_acctname_options
there was an option named: wp_user_roles
that had to be renamed to use the prefix: wp_acctname_user_roles

And in table: wp_acctname_usermeta
there was a meta_key: wp_capabilities
that had to be renamed to use the prefix: wp_acctname_capabilities

And there were some other meta_key names in the user_meta table that started with wp_ and were expecting the same treatment, so I changed those as well. But these 2 were the critical ones preventing logins from happening.

After making those changes, the login worked again.