Changing a wordpress user to an admin directly in MySQL Print

  • 0

If you have already had your username and password then you just need to update capability and role into a 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

a:1:{s:13:"administrator";s:1:"1";}.

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.

Additional Notes:

The roles are saved in form of serialized PHP array. Change the user role you want to assign to the current user by changing the meta_value as:

Subscriber
a:1:{s:10:"subscriber";b:1;}

Contributor
a:1:{s:11:"contributor";b:1;}

Author
a:1:{s:6:"author";b:1;}

Editor
a:1:{s:6:"editor";b:1;}

Administrator
a:1:{s:13:"administrator";b:1;}


Was this answer helpful?

« Back