Table of Contents
This knowledgebase article will educate you on how you can create a new WordPress Admin User using the database.
How to Create a New WordPress Admin User Using Database
The following steps will guide you step by step to achieve the objective of this guide.
Step #1
First of all, you need to gain access to your WordPress application’s database using any of the Cloudways supported methods for accessing the database. In this example, we are using the Cloudways Database Manager.
You will see a similar screen, as shown below, after accessing the database successfully.
Step #2
Now, you need to click on wp_users from the section located on the left listing all the database tables.
Tip
wp_users is one of the important database tables which is responsible for storing the information of registered users on a WordPress site. It only contains basic information such as user ID, username, display name, password, email, and a few more fields.
Step #3
Here you can add a WordPress user first and then assign admin-level capabilities.
Section A: Adding User
To add users, you need to click the New Item option from the top menu bar as this option will allow you to add a new record in the table.
Now, you need to enter the new user’s information in these respective fields in order to add a new admin user.
ID – You can input any unique number as a user ID or simply leave it blank to have an auto-generated ID. In this example, we are going with an auto-generated user ID.
user_login – Insert the username, which can be used to access the WordPress Dashboard. In this example, it is daviddoe.
user_pass – Add a password for the above username. Make sure to select md5 in the functions menu.
user_nicename – Put a nickname or any appropriate name for this user. In this example, it is David.
user_email – Add the email you want to associate with this account. In this example, it is [email protected].
user_url – Add the user’s URL, if any; otherwise, it can be left empty.
user_registered – Either you can define this information, or select Now in the functions menu to record the current time.
user_activation_key – This is used by WordPress to authenticate the reset password requests. It can be left empty for now.
user_status – Set this to 0.
display_name – Input a display name of the given user. In this example, it is David Doe.
Finally, click Save.
You can verify this new entry by clicking on the Select data from the top menu bar. Please take note of the user ID of this new user as it will be needed in further steps.
Section B: Assigning Admin Role
Here comes the final part of assigning the admin role to the newly created user. This can be achieved by adding a new entry in the wp_usermeta table. So, click on the wp_usermeta table from the section located on the left and then click New item.
Tip
wp_usermeta table is used to store the other information about the user. It basically extends wp_users with more data.
Now, you need to enter the following information in those given fields.
unmeta_id – You can leave this empty to have this auto-generated.
user_id – This is the ID of the user you created in the previous steps. In our example, the User ID was 10.
meta_key – wp_capabilities
meta_value – a:1:{s:13:”administrator”;s:1:”1″;}
Finally, click Save.
You can now log in to the WordPress Admin Panel using these newly created admin credentials. Click Here if you would like to know about the procedure of accessing the WordPress Admin Panel.
That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.