WordPress Admin: ‘You do not have sufficient permissions to access this page’

After restoring a database on WordPress and viewing the blogs, I was surprised to find that I couldn’t log into the Admin site and got an error ‘You do not have sufficient permissions to access this page’.

Going back a few minutes I had had a database error the first time I ran the application. The database I had exported from my Internet server had been set up automatically by my host and they had used a database prefix, something I hadn’t done when I installed WordPress on my local PC.

On line 62 in config.php I found the $table_prefix variable:

/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each a unique
* prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = ‘wp_’;

 

When I looked the the database using phpMyAdmin, I saw that all the tables were prefixed with ‘truewp’ (as in all lowercase), so I changed line 62 to:

$table_prefix = ‘truewp_’;

Now the main website displayed ok, but when I tried to log into wp-admin I got ‘You do not have sufficient permissions to access this page’. I didn’t expect that and I had a feeling that it wasn’t really a permissions problem although I did spend time looking at that side.

I went up to the original host site and looked at config.php and found that the definition on line 62 was actually:

$table_prefix = ‘Truewp_’;

with a capital ‘T’.

I changed my local definition to maintain exactly the same case and voila! It worked!

I don’t know if this is part of the behaviour or a bug, but I don’t like this type of thing. Either make it easy for the user NOT to get it wrong, make a relevant comment in the code or at least give a true explanation of the error.