Aug
28

How to solve ‘You do not have sufficient permissions to access this page.’ in WordPress

Uncategorized

I have been running into troubles logging in to WordPress and was kinda frustrated all morning.

Basically each time I use tried to log in, I get:

You do not have sufficient permissions to access this page.

I could not edit the blog, nothing works except the front page. I did a couple of searches at Google but the solutions didn’t seem to work for me.

In the end, I did a new installation of WordPress and scrutinized every damn thing in the users and usermeta table between a database that worked and a database that doesn’t.

Did you change the prefix of your table names in WordPress after the migration?

In my old database, I used ‘wp_’ as my prefix. As I migrated, I decide to use ‘wp3_’ instead of ‘wp_’. Unfortunately, the meta_key values are tied down to:

  • wp_user_level
  • wp_capabilities
  • wp_autosave_draft_ids

I need to update it to

  • wp3_user_level
  • wp3_capabilities
  • wp3_autosave_draft_ids

I wrote an SQL statement to share, just replace ‘prefix_’ with your new WordPress prefix. The following statements go to ‘meta_key’ and does a string replace from ‘wp_’ to ‘prefix_’.

UPDATE `prefix_usermeta` SET `meta_key` = REPLACE( `meta_key` , 'wp_', 'prefix_' );

(Make sure you do backups first! Note that the quotes used for string and field name are different.)

In the options table, there is ‘wp_user_roles’, make sure you get that changed into ‘prefix_user_roles’.

UPDATE `prefix_options` SET `option_name` = 'prefix_user_roles' WHERE `option_name` ='wp_user_roles' AND `blog_id` =0;

(Make sure you do backups first! Note that the quotes used for string and field name are different.)

With everything set, I tried logging in again and it worked. A happy WordPress user once again. I am using WordPress 2.2.2 before the migration and I did not upgrade WordPress during the migration. Hope it helps. (Applies to WordPress 2.3.3 also.)

Tags: , , ,

47 comments for “How to solve ‘You do not have sufficient permissions to access this page.’ in WordPress”

  1. Awesome fix you posted! With your clear instructions, I had it corrected in under 2 min. Thanks again.

    by dealasite (Aug 29, 2007 at 11 PM)
  2. You’re most welcome! Glad it helped. :D

    by Mr. Dew (Aug 30, 2007 at 2 AM)
  3. Thank you very much for yout tip. It saved me hours.
    Regards.

    by François-Xavier Bodin (Oct 4, 2007 at 6 PM)
  4. Wow - I was having exactly the same problem. This solved it! Thanks a bunch!

    by Arjun Prabhu (Oct 5, 2007 at 5 AM)
  5. Thanks for posting this information. I moved my Wordpress database and changed the prefix; the prefix thing is what got me. You saved me potentially hours of working trying to find the cause of my problem. Thanks again!

    by Brian Jarrett (Nov 5, 2007 at 5 AM)
  6. Thanks - saved me ages!

    by Julian (Feb 7, 2008 at 7 PM)
  7. [...] How to solve ‘You do not have sufficient permissions to access this page.’ in WordPr…If you rename the datbase table prefixes on an existing installation you will get bitten bu this. Simple fix takes a couple of minutes. wordpress howto [...]

    by Synesthesia » Links roundup for 2008-02-07 (Feb 8, 2008 at 8 AM)
  8. thanks a lot!!!!

    by piko (Feb 20, 2008 at 7 AM)
  9. ditto to all of the above. the admin for my Volleyball news site is now open for business once again - thanks to your tips.

    cheers
    Paul

    by Paul (Mar 3, 2008 at 10 AM)
  10. I owe you a beer! Thanks :)

    by Jacob Friis Saxberg (Mar 24, 2008 at 9 PM)
  11. Thanks for the help. Is there anywhere online where this design decision is explained? Is there a bug filed in Trac for this issue?

    by The Plaid Cow (Apr 3, 2008 at 12 PM)
  12. That was great info!

    I also found such records in the wp_options table as well, when trying to migrate, so whoever reads this be careful and look twice.

    by Takis (Apr 5, 2008 at 12 AM)
  13. Thanks for this info. Saved me a hard night of headaches. I was migrating one of my ebay wp sites into a new db. Glad I came across this.

    Big Mahalos to you!

    by chris (Apr 14, 2008 at 12 PM)
  14. Thanks this worked great.. thank god for Google and your blog post. :)

    Oliver Antosch
    from http://www.chinese-course.com/

    by Oliver (Apr 20, 2008 at 4 PM)
  15. nicely done, nicely done

    by WOOHOOO!!! (Apr 26, 2008 at 10 AM)
  16. Thank-you for posting this, it just saved me hours of head scratching!

    by Thomas M (May 2, 2008 at 12 AM)
  17. wow, thanks a lot! :)

    by andrea (May 3, 2008 at 3 AM)
  18. Thanks, your post saved me from getting a few more grey hairs.

    by David Valentiate (May 9, 2008 at 1 AM)
  19. thanks !! i was wondering how to get out of this mess myself..

    cheers,
    tom

    by tom (May 16, 2008 at 2 PM)
  20. fwiw, i tried both this approach and also mark’s approach (link above my comment) and neither worked. I finally imported the old version of my database and while the table names stayed the new name, I am now finally able to access admin functions! YEAH!

    by kathy (Jun 10, 2008 at 11 AM)
  21. Yeah, this doesn’t work for me either. Looks like it no longer works with current WP installations (2.5.1).

    by anysia (Jun 17, 2008 at 4 AM)
  22. I love you! I love you i love you i love you! It’s 5 am here and I’ve been panicking since I saw that error and google wasn’t helping then I saw this! I’m so glad you decided to share this, thank you so much.

    by Seluna (Jun 19, 2008 at 5 AM)
  23. Thanks, it’s work for me.
    I use this method directly with phpmyadmin and nothing difficult to do that.
    Thanks a lot.

    by lutfi (Jun 23, 2008 at 2 AM)
  24. Thank you, thank you, thank you!!!
    I spent AGES today trying to work this out - thanks!!!!!

    by Lorraine (Jun 25, 2008 at 8 AM)
  25. Saved me some headache, thanks for the great post.

    by zer0day (Jul 25, 2008 at 4 AM)
  26. did wordpress developers remove the prefix embedding from the table values in 2.5+? or are they continuing to keep wordpress as fucked as it always has been for every-13th-weekend warriors?

    by blow bird (Jul 31, 2008 at 3 PM)
  27. Just what I needed to fix my blog, thanks for the tips.

    by Adam Backstrom (Aug 7, 2008 at 1 AM)
  28. Thanks for the tips, so I could fix it in 5 minutes.

    But I used navicat for mac. Just get into the tables and changed the prefix in the 4 fields. No need to write sql statements.

    by filmbox (Aug 12, 2008 at 8 PM)
  29. I did the SQL here — and the force-upgrade.php from http://markjaquith.wordpress.com/2006/03/28/wordpress-error-you-do-not-have-sufficient-permissions-to-access-this-page/ — and was still having problems.

    Then I decided to look carefully at the prefix_usermeta database table, where I discovered that there were two records for prefix_capabilities. One had ‘administrator,’ the other ‘editor.’ I deleted the one with ‘editor.’ That finally fixed the problem.

    I’m not sure why there should have been two prefix_capabilities records. I wonder, however, if either the update process itself or force-upgrade.php may have inserted the additional record when it found no appropriate one because of the old prefix on the capabilities record…

    I suspect that all of the above was necessary for me. Perhaps it could possibly happen to someone else, also. Therefore this post.

    by Mike Green (Aug 16, 2008 at 4 AM)
  30. Very nice. Thanks :-)

    by kimalders (Aug 18, 2008 at 2 PM)
  31. will it work for 2.6 too :(

    by chandan (Aug 18, 2008 at 9 PM)
  32. I had the same problem. My solution was to re-edit the SECRET KEY section of the wp-config.php.

    You will need to put the SECRET KEY code above this line in wp-config.php

    /* That’s all, stop editing! Happy blogging. */

    by AW (Sep 14, 2008 at 9 AM)
  33. Thank you very much, I was installing a new plugin and had to migrate an existing blog into the new tables and was giving me many problems. This was the last problem and was about to give up - thanks!

    by Kerry (Sep 18, 2008 at 1 PM)
  34. thanks, this tip helped.

    by Joe (Sep 19, 2008 at 12 AM)
  35. A problem we hadn’t dealt with before, this was a very useful guide!

    by Dave (Sep 20, 2008 at 9 PM)
  36. Thank you so much, I’ve solved my issue.

    by California SR22 (Sep 21, 2008 at 10 AM)
  37. Thanks much for figuring this out!

    by Charlie R (Sep 25, 2008 at 2 AM)
  38. Just saved me from hours of troubleshooting!

    Thanks a bunch! :D

    by timkl (Oct 2, 2008 at 7 PM)
  39. Thanks a lot.

    by Alihan Çetin (Oct 13, 2008 at 9 AM)
  40. Brilliant. Thanks for this info. Worked flawlessly.

    by Aaron forgue (Oct 14, 2008 at 11 PM)
  41. I still can’t get it to work, after adding Secret key, changing prefixes in all the db’s… This is wearing me down…

    by sven (Oct 17, 2008 at 7 PM)
  42. Thanks. It works for me.

    by Steve (Oct 24, 2008 at 4 PM)
  43. Just fixed my 2.6.2 version with your tips… this would have been a real bear to track down without your help. Much appreciated.

    by Ron Amundson (Oct 26, 2008 at 11 PM)
  44. is it possible to move multiple wordpress into one database and have different prefixes for each site?

    by Barry Main (Oct 28, 2008 at 11 PM)
  45. A great post, I don’t know a great deal about sql but this really helped me transfer my wordpress site in no time.

    Many thanks for the instructions

    by Water (Nov 2, 2008 at 11 PM)
  46. Thanks a bunch! You saved my bacon.

    by Mark (Nov 21, 2008 at 10 AM)
 

Leave a Reply

 

Comments may be moderated due to spam. No advertisements are allowed in comments.

You'll require some math knowledge to comment, this is done to stop evil bots from spamming my blog.

Read my comments policy

Want a display picture?