How To Create A New WordPress Admin User In phpMyAdmin

Sometimes a client will give you cPanel access to a WordPress website, but not the login details for an admin.

Other times, you might find yourself locked out of WordPress, or the site got hacked and the password changed.

Whatever the reason, you might need to manually create a new admin user through the database.

How to create a new WordPress admin user in phpMyAdmin:

  1. Go to wp_users and copy a current user
  2. Change the login details to the new user and add the password as MD5
  3. In wp_usermeta, add rows connecting wp_capabilities and wp_user_level to the new user ID.

Let's go through those steps in detail.

Go to wp_users and copy a current user

Login to your cPanel and go to phpMyAdmin

Go to the wp_users table in your database.

If your database uses custom prefixes, then you might not see wp_users. Whatever the prefix, you need the row that ends with _users.

You should see one or more users in the database.

Click "Copy" on one of the rows.

You'll be taken to a new screen which has all the details of the user you copied already filled out.

Change the login details to the new user

Change the following fields to what will become the login for your new user:

  • user_login
  • user_nicename
  • user_email
  • display_name

You can set user_login, user_nicename and display_name to be the same thing.

In this example, I'll put "tom" into those three fields and Tom's email into the user_email field.

Don't put anything into the ID field. phpMyAdmin will set the ID automatically when you save the row.

Add your password in plain text to the user_pass field. Don't use an apostrophe in the password. You can use spaces, alphanumeric characters and some special characters. You don't need to get too crazy with the password if you're going to change it in the backend later.

In the function dropdown next to user_pass, choose "MD5". This will convert the password to a hash, which is how WordPress stores passwords in the database.

Click "Go" to save the row and return to the wp_users screen.

This will create the new user.

Connect the admin ID to user capabilities and level

Before you move on to the next step, take a note of the ID of the user you just created.

In this example, the ID is "2", but it might be different for you.

The ID will be created automatically by incrementing from the last created row, but don't assume that if the only other ID is 1, that the new ID will be 2. If it is higher, it's because at some point there was another user which had the ID of 2 or higher.

Go to the wp_usermeta table and look for an admin user.

Click "Copy" on the wp_capabilities row.

A new screen will open with the admin's details filled out.

Just change the user_id to your new admin user. In this example, the new admin's ID is 2.

If you inserted a new row, rather than copying a current admin, you need these values:

  • user_id: 2 (or whatever the ID of the admin you created is)
  • meta_key: wp_capabilities
  • meta_value: a:1:{s:13:"administrator";b:1;}

Don't insert anything at umeta_id. phpMyAdmin will take care of that.

Click "Go" to save the row and return to the previous screen.

Copy the wp_user_level row, the same way you did with the wp_capabilities row.

You'll be taken to a new screen.

Change the user_id to the ID of the admin you created. In this example, the ID is 2.

If you inserted a new row, rather than copying a current admin, the information you need to enter is:

  • user_id: 2 (or whatever the admin's ID you created is)
  • meta_key: wp_user_level
  • meta_value: 10

Don't add anything to umeta_id as phpMyAdmin will automatically assign that.

Click "Go" to save the row.

That's all you need to do to create a new WordPress admin user through phpMyAdmin.

You can go ahead and login to the WordPress dashboard using the credentials you created.

Leave a Comment