WordPress Using phpMyAdmin to add a New User

Wishing to add a new administrator user to a WordPress website. How could I do this if I don’t have access to an existing user account?

Fortunately I had access to the hosting control panel giving me the option to use phpMyAdmin.

The equivalent actions can be created by the use of a custom php file, which is saved on the website and run once. There can be something comforting about interacting with forms rather than composing a piece of script. Potentially less chance of making an error with the forms. A script can be harder to view for malicious intent, or simply an error in copying and customising to the particular circumstance, can be catastrophic. Having said that it can be easy to click on the wrong button, a delete rather than insert, as the page is rendering.

A new user can be added to a WordPress website using phpMyAdmin, available through the hosting control panel.

Take care there are steps involved in this article which seriously affect your website.

Using phpMyAdmin we’ll add a new administrator user.

Login to your control panel and open phpMyAdmin. This is likely to be found on a page with a number of other icons. Finding this page will depend upon the layout of your hosting provider.

Once opened shown on the left are the databases associated with the account. If it’s not clear which one is used by the website this will need to be discovered.

To check which database is in use by the website return to the website control panel and click on the icon for the file manager. This will show a directory and file view. You may need to navigate into a folder called public_html. Look for and open a file called wp-config.php.

Using phpMyAdmin add user wp-config

Here we are looking for the entry define(‘DB_NAME’, ‘wordpress’); In this example the database is wordpress. Note this value, it is the database which we wish to select within phpMyAdmin.

Back to the control panel view of icons. Select phpMyAdmin once more. In the left view of the phpMyAdmin page there’s the list of databases. Select the one found previously.

Using phpMyAdmin add user table overview

WordPress uses a default table prefix of wp_ however It’s possible that the prefix of your tables may be otherwise. For ease I’m using the default in my references.

The tables which we are interested in are wp_users and wp_usermeta.

I have found that clicking on a table in the left menu list of tables allows me to see the entries and to edit these but I can’t add (insert) a new row. To do this it’s back to the list of tables in the main window with the edit options along side to the right in the row. Here I select insert.

Insert new user in table wp_users

Click on insert to open a clean entry form to add our new user details.

Using phpMyAdmin add user wp_users insert entry

In this view the fields are completed as follows:

  • ID: leave this entry
  • user_login: the login username, take care to avoid obvious entries, such as the person’s name. But, including a part of the users name will help in identification. Mix it with some additional random characters.
  • user_pass: a password for the user. Select md5 from the dropdownlist to the left and enter the password. Take care to ensure suitable complexity.
  • user_nicename: the name by which the user will be known.
  • user_email: the email address for the user
  • user_url: the website for the user, its possible that its the same as the website.
  • user_registered: select the date when the user was registered. Unless you are obsessive regards the date/time select yesterday’s date – its probably close enough.
  • user_activation_key: leave this entry
  • user_status: leave this entry
  • display_name: the name shown

Add user role abilities in table wp_usermeta

If we leave our newly created user as is we’ll be able to login but not a lot else.

Our aim is to create a new user with administrator privileges. To do this we set the capabilities of the user

If you didn’t note the id for the newly created user revisit the wp_users table to make a note of it.

Back to the home screen view of the database with the tables listed click on insert on the row for wp_usermeta.

Using phpMyAdmin add user wp_usermeta wp_capabilities

Fill in the I’d for the user, plus the fields

  • umeta_id: leave this entry
  • user_id: enter the user id value
  • meta_key: wp_capabilities
  • meta_value: a:1:{s:13:”administrator”;s:1:”1″;}

If you have changed your database prefix from wp_ don’t forget that wp_capabilies will also need to change accordingly.

There’s another entry in the wp_usermeta table to add

Using phpMyAdmin add user wp_usermeta wp_user_level

The values for this one are:

  • umeta_id: leave this entry
  • user_id: enter the user id value
  • meta_key: wp_user_level
  • meta_value: 10

A review of the list of entries, looking at the last page:

Using phpMyAdmin add user wp_usermeta list

That leaves trying to login with your newly added user and seeing whether you have administrator rights over the website.

A few simple steps, along with access to phpMyAdmin via the website hosting control panel, can be used to add an administrator user to an existing WordPress website.