I am trying to set up a local copy of a production WordPress blog. On production, I am a user but not an admin, so I am trying to change myself to an admin locally. I was following the directions on this blog post to make myself an admin, so I performed the following SQL queries:
INSERT INTO usermeta(user_id,meta_key,meta_value) VALUES(376, 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');
INSERT INTO usermeta(user_id,meta_key,meta_value) VALUES(376, 'wp_user_level', 10);
Then I cleared my browser cookies and logged in again, but when I tried to navigate to http://localhost/wp-admin
I still got “You do not have sufficient permissions to access this page.” I even went so far as to delete my APC cache files and reload Nginx and PHP-FPM, which also didn’t change anything. Does anyone know of anything else to try?
To set the
capabilities
anduser_level
yourmeta_key
value needs to match your database prefix. By default this iswp_
(resulting inwp_capabilities
andwp_user_level
) however it would be different in your case as you don’t have a prefix. The propercapabilities
value isa:1:{s:13:"administrator";s:1:"1";}
.Here is how to change assign a User to the Admin Role in WordPress using MySQL statements:
If you have already have your username and password then you just need to update capability and role into database.
Go to wp_user table and locate your ID from there i.e. in my case its 2. And then go to wp_usermeta and look for meta_key = wp_capabilities and user_id – 2. Edit that row and change meta_value to
Again go for meta_key = wp_user_level and user_id = 2. Edit that row and change meta_value to 10. Don’t change other rows where user_id is not your own.
See my wp_users table.
See my wp_usermeta table.
Two queries will be fired something like these: