Losing access to a website’s control panel has happened at least once to every WordPress user involved in website creation. Most of the time, it’s a matter of forgotten password. In this case, you can easily recover the password using the recovery email or by changing it directly in the database.
However, in other less common cases, re-accessing the dashboard can be quite a problem. Administrator accounts are most affected by this as they have the most privileges. These other reasons for losing access to the control panel include accidental deletion of the user account or your website being hacked; this may cause some accounts to be deleted, including your single administrator account.
It is also possible that you only have one administrator account linked to your previous webmaster; this account caused you to be unable to login to your admin dashboard or any of your non-admin accounts when leaving.
Knowing how to add a WordPress user via phpMyAdmin can come in handy in these situations. This is especially true for adding administrator accounts and therefore these will be the main focus of this article. However, we’ll also show you how to add accounts with default (non-administrator) user roles if you need to do it outside of your control panel.
How to add a user to WordPress database via phpMyAdmin
Now that we’ve covered why it would be helpful to know about other ways to regain access to your dashboard, let’s move on to how. You must have access to your web host control panel to be able to follow our suggested methods. We will use cPanel in our examples.
In the following section, we will show you how to add a WordPress user and assign administrative privileges to them via phpMyAdmin. We will also discuss how the process will be different if you want to assign other non-admin privileges. Since this guide requires you to directly edit your database, it is highly recommended to make a backup beforehand.
Firstly, connect to cPanel using your cPanel credentials and click phpMyAdmin choicecontained in databases section near the top of your screen.
After clicking it, phpMyAdmin will open in a separate tab. Find your database in the left menu and click on it to open, then Find the wp_users table and click on it.
Before we go any further, we should quickly address two issues you may encounter while performing the steps outlined above.
No need to worry if you forgot your database name; It is stored in the wp-config.php file. To find it, simply look in the wp-config.php file and look for a line of code specifying your database name.
By doing so, return to the main view of your server control panel and click File Manager choice located at the top of your screen.
In the tab that opens, find your website and go to root WordPress directory, is usually called public_html. After that, Find wp-config.php file, click on itand choose opinion option from the drop-down menu.
This will allow you to see the contents of the wp-config.php file. In the MySQL settings section near the top of the file, look for a line of code containing your database name. It will be in the following form:
define( 'DB_NAME', 'your-database-name-here' );
‘ partyour-database-name-here‘ will be replaced with the actual name of your database.
Some users may decide to change the default WordPress database prefix (which wp_) for security reasons. If that’s the case with you, you should look for the database table yourprefix_users instead of wp_users. Please note, the section with your prefix_ will be replaced with your custom prefix. Knowing your database prefix is very important and will be mentioned several times throughout the article.
That said, we can continue with our guide to using phpMyAdmin to add an admin WordPress user. after reaching users You will be placed inside the table. Search tab. Click Sting tab instead, at the top of your screen.
To add a user, You will need to fill in the values of the columns shown above. Sting tab. Let’s take a brief look at what they are:
– ID – unique number assigned to a user when created,
– user_login – username of the user you want to create,
– user_pass – the password of the user you want to create,
– user_nicename – a name the user will refer to,
– user_email – email address of the user you want to create,
– user_url – URL of the user if there is a site or social media profile they want to link to,
– user_registered – date the user was created,
– user_activation_key – the key used for authentication when resetting the password,
– user_status – a number that identifies the user’s status (currently deprecated), and
– display_name – the name of the user displayed on the website.
To add a new user, you must fill in the following fields: user_login, user_pass (when choosing MD5 encryption function), user_nicename, user_email, user_url, user_registered and display_name. When you’re done adding the required information, Press To go button below.
Apart from the options we mentioned, we have set the others to their default values. Of the remaining three options, identity is the most important and It will be created automatically after the user is created.
Wait until the creation process is finished; You will see a success message similar to the one shown below.
After that, Click the Browse tab to access once again. Here you can see the ID of the newly created user; You will need this information later, so be sure to memorize it. In our case, it was 17.
At that time, return to the main screen of your database and click wp_usermeta table to access it. As we mentioned earlier, if you have changed the default WordPress database prefix (wp_), you should look for the table named prefix_usermeta.
Next, click Sting tab. You will see a screen similar to the one below, here there are two sections where you need to add data.
This is the last and most important step—assigning a user role to the newly created user. All the steps we’ve described so far will be the same whenever you create any new user, regardless of their role. Let’s take a look at how you can assign administrative privileges to your new user.
In the first part, add id you memorized before as the value of the user_id column. then set wp_capabilities as the value of the meta_key column. Finally add the following code As the value of the meta_value column:
a:1:{s:13:"administrator";b:1;}
If you have changed the database prefix, you must change it as well. wp_ Part of it wp_capabilities to match your custom prefix.
After that, Proceed to the second part. add user_id once again, set wp_user_level Enter 10 as the meta_key value and the value for the meta_value column. At that time, Press To go button to assign administrative privileges to this new user.
Immediately after, You will see a success message in the form of a query that is run thanks to the data you entered.
After that, You can login to your website with your new username and password. If you lost it before, you created your website and regained access. You can use this new admin user as you see fit, including using it to recover your previous admin account.
How to add a user with non-admin user role to WordPress database via phpMyAdmin
As we mentioned earlier, any user creation process is the same in phpMyAdmin. The only difference between an administrator and any other user role is wp_usermeta table.
Then, we recommend that you review previous episode first to learn how to create users. You can follow the same steps by accessing the section. wp_usermeta table. at that point you Reach wp_usermeta tableyour property switch Sting tab. You will see a view similar to the one below showing two subsections.
In the upper part, You must add the id of the user you created as the value of the user_id column. Also, in summer wp_capabilities in the value field of the meta_key column.
At that time, scroll down to subsection and Enter your user’s ID in the value field of the user_id column. Set wp_user_level in the value field of the meta_key column. If you followed the part of this article explaining how to assign an administrator user role, you probably We realized that the steps we took were the same. This is because different user roles are assigned to users based on entries in the meta_value fields associated with the users. wp_capabilities and wp_user_role meta_keys respectively. Below you can see the entry for these fields for all default non-admin user roles.
wp_capabilities:
a:1:{s:10:"subscriber";b:1;}
wp_user_role: 0
wp_capabilities:
a:1:{s:11:"contributor";b:1;}
wp_user_role: 1
wp_capabilities:
a:1:{s:6:"author";b:1;}
wp_user_role: 2
wp_capabilities:
a:1:{s:6:"editor";b:1;}
wp_user_role: 7
Let’s explain this in more detail using an example.
If we want to assign the subscriber user role to our new user, a:1:{s:10:”subscriber”;b:1;} directly into the value field of the meta_value column below wp_capabilities meta_key value. Also, we add 0 to the value field of the meta_value column, directly below the column. wp_user_role meta_key value. After that, Press To go button to finish the process.
If you followed all the steps correctly, the success message should come shortly.
All remaining user roles are similarly assigned using appropriately. wp_capatibilites and wp_user_role values given above.
final thoughts
Knowing how to create a WordPress user with phpMyAdmin is a useful skill. It is especially valuable if you are unable to create users in your dashboard or need to recover your account but the usual methods fail. While this information is most valuable for creating users with administrative privileges, it can also serve to create users with different user roles. So, to use phpMyAdmin to add a user, all you have to do is follow this article and you’ll be done in a few minutes.
Support our work ❤️
If you enjoyed this article, consider leaving a tip to help us keep publishing great content.
























