WordPress – How To Manually Add New Admin User From MySQL Database

Share

If somehow you are locked out of the WordPress admin but have access to the database, you can follow the below steps to manually create a new WordPress admin user account to regain access to the admin dashboard.

1. Open the table wp_users (where wp_ should be replaced with the table prefix used in the database)
2. Insert a new row with the following data –

ID – keep blank
user_login – the username for the new account
user_pass – the password for the new account (If you are using PHPMyAdmin choose MD5 from the Function dropdown. Or else convert the password to MD5 and then enter the converted value)
user_nicename – Enter a nickname for the account
user_email – The email address that you want to use with this account
user_status – 0 (zero)
display_name – Display name for the new user

Rest of the fields can be left blank

3. Note down the ID of the inserted row
4. Open table wp_usermeta (where wp_ should be replaced with the table prefix used in the database)
5. Insert a new row with the following data –

umeta_id – keep blank
user_id – Enter here the ID noted down in step 3.
meta_key – wp_capabilities (where wp_ should be replaced with the table prefix used in the database)
meta_value – a:1:{s:13:”administrator”;b:1;}

6. Insert another row with the following data –

umeta_id – keep blank
user_id – Enter here the ID noted down in step 3.
meta_key – wp_user_level (where wp_ should be replaced with the table prefix used in the database)
meta_value – 10

That is all it takes to add a new admin user with administrator role. Log in to WordPress admin now with the username / password provided in step 2.

This entry was posted in Wordpress and tagged , , . Bookmark the permalink.
 

3 Responses to WordPress – How To Manually Add New Admin User From MySQL Database

  1. The steps are clear and easy to understand. This is really helpful.

  2. Chris Smith says:

    Thanks for the great tutorial. Sometime these easy things become complex for someone.

Leave a Reply

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

*