Did you know that you can add a new user to WordPress via the database? In this article I show you how!

Recently, when migrating my clients’ website to a new web host, I found myself without a user account with which I could access the WP Admin. So rather than wasting my clients time with such inconveniences, I decide to simply go about it anther way.

By following these steps, you will be able to create a new user for the WordPress Admin should ever find yourself without the appropriate account or if you are ever locked-out as a result of a hijack by hackers (*shudders*).

 1: Backup

Don’t make any changes before you backup. This maybe a simple modification in terms of what you could be modifying, but it still has the potential to breaks things so that your site is unusable.

2: Edit the wp_users table

Open phpMyAdmin for the server on which your WordPress website database in located

Open phpMyAdmin in cPanel

Open phpMyAdmin in cPanel

Then, go to your database in the sidebar, and open the wp_users table

Open the wp_users table in your database

Open the wp_users table in your database

In the wp_users table, press the “Insert” tab, which will allow you to create a new record into the wp_users table with the following values:

  1. ID: a unique value not already in use, e.g. 9999
  2. user_login: the username for login, e.g. etalented
  3. user_pass: select MD5 under Function and enter the password for login, e.g. etalented
  4. user_nicename: can usually be the same as user_login- it is what is used for the slug
  5. user_email: the email address you want for this user, e.g. [email protected]
  6. user_url: doesn’t need a value
  7. user_registered: pick todays date from the data picker, the format will be YYYY-MM-DD HH:MM:SS
  8. user_activation_key: doesn’t need a value
  9. user_status: 0
  10. display_name: the value entered here will be the name displayed in the admin bar after login, e.g. etalented

When you are happy, press the “Go” button

Add a new record to the wp_users table

Add a new record to the wp_users table

3: Edit the wp_usermeta table

Now, you need to open the wp_usermeta table in your database

Open the wp_usermeta table in your database

Open the wp_usermeta table in your database

In the wp_usermeta table, press the “Insert” tab, which will allow you to create a new record into the wp_usermeta table with the following values:

  1. umeta_id: doesn’t need a value
  2. user_id: enter the ID that you entered for ID in the wp_users table, e.g. 9999
  3. meta_key: enter wp_capabilities
  4. meta_value: enter a:1:{s:13:"administrator";s:1:"1";}

When you are happy, press the “Go” button

Insert a new record to the wp_usermeta table

Insert a new record to the wp_usermeta table

You now need to insert another record into the same table with the following values:

  1. umeta_id: doesn’t need a value
  2. user_id: enter the ID that you entered for ID in the wp_users table, e.g. 9999
  3. meta_key: enter wp_user_level
  4. meta_value: enter 10

When you are happy, press the “Go” button

Insert a new record to the wp_usermeta table

Insert a new record to the wp_usermeta table

Done!

You should now be able to visit the WP Admin login page of your WordPress website and login with the username and password that you have used above.

Did you have any problems with this method? Please do let me know in the comments below…

Questions or comments?

I've made it very easy for you to send me a question or a comment regarding what you have just read - all you need to do is login with Facebook below, post your question, and I'll reply directly.

Pin It on Pinterest