Under normal circumstances, if you have lost access to the WordPress administration area, you can simply use WordPress’ password recovery feature to reset your password. However, there are some cases when this isn’t possible.1 Fortunately, if you can access the database directly, it is easy to add an admin user.

This tutorial will show you how to manually add an admin user via phpMyAdmin.2

Step 1: Log into phpMyAdmin & Locate The Database

If you have FTP access, the quickest way to retrieve the database details is by opening up the wp-config.php file located at the root of the WordPress installation.3 However, if you do not have access to this file, you can log into phpMyAdmin and verify that you are looking at the proper database by matching the site urls in the wp_options table.

Step 2: Add a User to the wp_users Table

You will now need to add a new user. On most installations, the table that you need to find is wp_users, as shown in the image at left.4 To get to the table, just click on the table’s name.

Next, click on the Insert tab. (You will find the insert tab in the horizontal list of links located across the top of the page. See the image at left.) This will bring up an insert form which will allow you to add new values to the table.

user_nicename – enter a name or an alias, do not enter the user login name

user_email – enter an email address for the user

user_url – optional

user_registered – select a date using the date selector

user_activation_key – leave blank

user_status – leave default value of 0

display_name – enter same value as nicename

After submitting the form, note the user ID that was automatically created for the new user account. You will need this to assign the proper administrator permissions.

Step 3: Assign Admin Permissions

Now, go to the wp_usermeta table and click the insert tab to go to the phpMyAdmin insert forms. You will need to add two rows. First, enter the following:

umeta_id – leave blank (this is automatically generated)

user_id – ID of the user you created

meta_key – enter wp_capabilities

meta_value – enter a:1:{s:13:"administrator";b:1;}

Now insert one more row with the following:

umeta_id - automatically generated

user_id – use the ID you created

meta_key – enter wp_user_level

meta_value – enter 10

And that’s it. After inserting the above information, you can now go and log into the WordPress admin area using the new user account that you just created.

This might happen if a) you have lost access to the admin email address, b) your WordPress installation cannot send email, or c) if you need to access the WP admin area but your client has not given you access credentials. [↩]

Note: There are other ways to add an admin user, such as via command line or by writing a php file to handle the request. [↩]

This file will tell you the database name as well as the table prefix. [↩]

Note: If the table prefix has been altered, all tables will have slightly different names. The table prefix can be found in the wp-config.php file. [↩]

Incidentally if you are doing these steps from a database tool that doesn’t make it easy to set a password, you should be able to put more or less anything in the password field, then use the ‘recover your password’ facility to set a new one.