How to create a WordPress admin user using PHPMyAdmin

How to create a new WordPress admin user through phpMyAdmin

There may come a time when you need to create an admin user directly in the WordPress database. This method can come in handy if you have forgotten your admin password and WordPress is not sending out a password recovery email.

The first thing you need to do is log in to your phpMyAdmin control panel. Once logged in, the sensible thing to do from here would be to download a database backup, once you have a backup in place follow the following steps.

Click on the wp_users table, but just check your prefix as it may be different from the default, it may not contain wp_ so look for a table that ends in _users.

Click on the _users table

Now that you have loaded the wp_users table, click on the Insert tab on the options menu.

Click on the Insert tab

Now fill in the following fields:

ID : Any number you want, I have used 28
user_login : Enter the new admin username, I have used adminuser2
user_pass : Enter the new admin user's password. Make sure to select MD5 in the functions menu
user_nicename : Enter the new user's nickname, I have used adminuser2
user_email : Enter the new admin user's email address
user_registered : Set the date and time when this user is registered.
user_status : Set the user status to 0
display_name : Enter the name that will be displayed for this user on your site

Double check your entries, if you are happy click on the GO button. You will see the following screen confirming the new row insertion.

Now click on the wp_usermeta table and then click insert, just like you did previously.

Click on the _usermeta table and then the Insert tab

Now fill in the following fields:

user_id : Is the ID you entered in the previous step, I used 28
meta_key : Enter the phrase wp_capabilities
meta_value : Enter the following meta value a:1:{s:13:"administrator";s:1:"1";}

Double check your entries, if you are happy click on the GO button and click on the Insert tab again and fill in the following fields:

user_id : The ID is the same number you entered in the previous step, I used 28
meta_key: Enter the phrase wp_user_level
meta_value : Enter the value number 10

Double check your entries and the click Go. You have now succesfully added a new admin user.

If you wanted to take a faster approach, you could just run the following SQL query to add a new admin user. Just remember to change the values.

To run the query, click on the database name, then to the right click on the SQL tab, insert the following query and hit GO.

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('adminuser2', MD5('adminuser2password'), 'adminfirstname adminlastname', '[email protected]', '0');
 
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
 
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');

Now you can head over to your wp-admin and login with the new credentials.

Share:

Facebook
Twitter
LinkedIn

Found This Useful?

Follow us on Twiiter for the latest updates and FREEBIE announcements

You May Also Be Interested In

Comments