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.)
Thanks a lot, I almost kill my self before I read your post. Complete in just 1 minute…You’re good..
wonderful,i wasted around 2 hours to get rid out of this situation. thanx
Thanks a lot for this! You saved me quite a lot of time of research
Thank you very much….
Great thanks.
Works for me using 3.2.1
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.
Very useful article! It helped me secure my weblog successfully, and saved much googling time. Thanks a ton!
Thank you very much, you saved my life
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!
Works for me too. Awesome fix. THANKS!
Thanks so much for this post…really save me time searching what is wrong with my wp installation..
It’s still working for WordPress Version 3.2.1.
thanks for this usefull information, now i can worpressing again,,
thanx mate
saved a lot of time
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.
This post is a live saver! I love wordpress, but little problems like this or how to bulk delete comments, do drive me crazy.
You sir, rock. You just saved me a whole bunch of hassle, this was exactly my issue!
Fantastic explanation! Thank you very much for this post!
Thank you! You saved my life. Now I’m facing the other theme of my wordpress.
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.
thanks you very much
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
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
Thank you!!!!!!!!
Thanks, this was freaking me out. I don’t get it why WordPress would hardcode these prefixes in the DB. Well thanks
Thank You. Less than a minute, I fixed it.
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 :/
Kudos! You saved the day with 2 wonderful MySQL statements.
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.
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.
I love you, this saved me! You’re a hero, thank you!!
Andy
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
Indeed it was of great help. Thanks a ton!!!
Thanks, you added the last piece to my quest.
I was missing the wp_user_roles option in my actions.
thanks so much, this is still working fine even years later.
Pingback: You do not have sufficient permissions to access this page. [solved] | terima kasih sudah mampir dimari :)
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!
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.
Thanks a Lot u r a life Savior!!
After two days of research, this was right solution to my problem. WordPress’s stupidity is endless…
Thank you!
Genius, thanks so much, worked instantly!
Howdy,
It worked for me. I changed the tables prefix but the database was missing the later query.
Thanks a lot!
Thanks. This saved my time. Great Job dear.
Thanks a Lot, it worked great!!!
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..
This has saved my company lots of time.
Thank You
you are god sent! AWESOME FIX
It work’s mate. Thanks for great post !!