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

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, lately, it seems to be working for WordPress 2.9 also.)

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

  1. ipank

    Thanks a lot, I almost kill my self before I read your post. Complete in just 1 minute…You’re good..

  2. Paul Underwood

    Hi

    I got this same problem this morning, updated my PHP and my dev site and broke everything. Had to reinstall wordpress but nothing was working. Got this error message and did your fix of changing the prefix table names and it now works.

    Thanks.

  3. Michael Garcia

    Like everyone else has said… you saved me tons of time. I hope you are living a happy life because you just made mine better! Ran your SQL scripts and it fixed my WP login errors. Thanks!

  4. beba

    Thanks so much for this post…really save me time searching what is wrong with my wp installation.. :D It’s still working for WordPress Version 3.2.1.

  5. Terry

    You posted this solution on Aug, 2007 and IT’S STILL HAPPENING!

    But it worked great. Thank you, thank you, thank you for giving me the hours and hours it would have taken me otherwise back to my life.

  6. Jason

    This post is a live saver! I love wordpress, but little problems like this or how to bulk delete comments, do drive me crazy.

  7. Jason King

    I had this problem after moving a website to a new hosting company.

    When importing the MySQL data, the database prefix had changed to lower case. All I need to do was amend my config.php file to match.

    Of course it took me hours to figure that out.

  8. Gareth

    Thank you. My life can now move on, really, really appreciate your time and effort on publishing this, your wordpress compassion goes along way

    Cheers,
    Gareth

  9. Amy

    I was dealing with this for a few days. Your blog saved me! I thought I was going to go insane! Thank you so much :)

  10. Matthijn

    Thanks, this was freaking me out. I don’t get it why WordPress would hardcode these prefixes in the DB. Well thanks :)

  11. Peter

    I decided to move various WordPress installations into one database expecting to be able to simply change the table prefix in the config file only to find I was suddenly locked out.

    Why on earth does WordPress hardcode the prefix inside database values?!

    Thanks to you, I have them all working again now, I wish yours was the first article I’d found :/

  12. Douglas d'Aquino

    THANK YOU, after looking for at least 10 solutions without success, yours really did it! Thanks for the tip, now I’m aware of these details and will remember to use the same prefix while developing and deploying, so the database import won’t be a problem.

  13. Finn

    Thanks a lot. I just moved a site and could not get in. Found the meta key in options, but did not see the ones in usermeta until I read your post.

    Thanks.

  14. CanalCoffee

    Still use full post!! I’ve made a french translation of this for lazy frenchies, many many thanks U help me a lot this morning ! Cheers

  15. Pingback: You do not have sufficient permissions to access this page. [solved] | terima kasih sudah mampir dimari :)

  16. sam dawson

    Thank you very much for this information. It’s a good thing that I was able to visit your blog. Now I have a better idea on how things work in WordPress. Keep it up!

  17. Gyp The Cat

    You are a god among men :) Thank you, stopped me from loosing any more hair than I was doing before WP decided to really complain after a migration.

  18. Vladimir

    After two days of research, this was right solution to my problem. WordPress’s stupidity is endless…

    Thank you!

  19. D

    Simply great info… Thanks alot I wasted 2 hour on WordPress forum but didn’t found any solution. This info really saved my lots of time..

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please leave these two fields as-is: