Admin User

How to Add Admin User to WordPress Database via MySQL: Step-by-Step Guide

Admin User
Struggling to access your WordPress admin user account after a hack or forgotten password? Wondering how to regain control of your WordPress site?

Having a WordPress site carries risks including common security breaches. If your WordPress website security is compromised, or you’re locked out of the WordPress admin dashboard due to a forgotten password, there’s no need to panic.

You can regain access to your user account by creating a new WordPress admin user directly through your site’s database table. This method is particularly useful if hackers have removed your admin account from the database and not let you access you your website dashboard.

In this post, we’ll guide you on how to add an admin user to the WordPress database using MySQL so you can get access to your site. Before directly jumping onto the procedure of adding an admin user, let’s understand why it is important to do it via SQL

Why To Add An Admin User To The WordPress Database Via MySQL

Adding an admin user to the WordPress database via MySQL can be a great solution in situations where you’ve lost access to your WordPress admin dashboard

There can be various reasons for this such as a forgotten password, a hacking attempt, or some other unforeseen circumstance, but gaining access through MySQL can provide a quick solution.

So, why is it important to use SQL for this task?

MySQL allows direct access to the WordPress database. This eliminates the need for a functioning admin user account. This means you can make changes to the database structure and content, including user accounts, without accessing your WordPress admin interface.

By using MySQL, you have greater flexibility and control over the user creation process. You can customize user privileges, and set strong passwords to protect your site.

When you are not able to access your WordPress admin dashboard, using MYSQL to add an admin can serve as an emergency access method. 

Now that we understand the importance of using MySQL for adding an admin user let’s proceed with the step-by-step guide to regain access to your WordPress site.

Adding An Admin User To The WordPress Database Via MySQL

Adding an admin user to the WordPress database using MySQL is an effective solution. Let’s proceed with the step-by-step guide to get access to your WordPress website.

Step 1: Access MySQL Database (phpMyAdmin)

To create a new admin user account, first, you’ll need to access phpMyAdmin. 

It is a free software tool, coded in PHP. This allows you to manage your WordPress database. You can typically find a link to phpMyAdmin in your WordPress hosting account dashboard. 

Look for options like- phpMyAdmin, and Database Manager

Note- The name might vary depending on your hosting provider. For example, in cPanel dashboard, you’ll see phpMyAdmin

Step 2: Access the wp_users Table

Once you’ve logged into phpMyAdmin and selected your hosting account’s database, it’s time to locate the wp_users table. This table has information about user accounts, including usernames, passwords (encrypted), email addresses, and other user-related data.

You can typically find the wp_users table listed among other tables in your WordPress site’s database. However, it’s worth noting that some hosting providers may modify the default table prefix (wp_) for security reasons. 

For instance, instead of wp_users, you will see tables named wpud_users or something similar. Simply find the table that contains user data for your specific WordPress site.

Once you’ve identified the wp_users table, click on it to proceed with adding a new admin user directly to the database.

Step 3: Adding a New WordPress Admin User in the Users Table

Within the wp_users table, locate the Insert tab. Click on it to proceed with adding a new admin user. This action opens up a form where you can enter details for the new user account.

You need to enter the following details in the form:

  • user_login: Here, you’ll insert the username for the new admin user. Choose a username that is unique and easy to remember.
  • user_pass: In this field, you’ll set a password for the admin account. It’s crucial to select a strong password to enhance security. To encrypt the password, select “MD5” from the Function drop-down menu.
  • user_email: This email will be used for important communications and password resets. So, enter a valid email address associated with the new admin user.
  • user_registered: Select the date and time for when this user account should be registered. This field is particularly useful for maintaining a clear record of user registration dates.
  • user_status: In this, set this value to zero. This indicates that the user is active.

Note- Avoid using generic usernames or easily guessable passwords to avoid unauthorized access to your WordPress site.

As you have entered the necessary details, scroll to the bottom of the form and click the “Go” button to submit the information.

Once the form is submitted, you will receive a confirmation message indicating that the new admin user has been added to the wp_users table. 

Moreover, you can verify the addition of the new user admin account. For this, you need to go back to the wp_users table and check new user entry is visible. Take note of the value in the ID column, as it will be required for the subsequent steps.

Step 4: Insert User Meta Values

Next, go back to the wp_usermeta table and click on “Insert.” Again, the table name may be different depending on your hosting provider. Generally, it’ll look like- [something]_usermeta.

Once inside the wp_usermeta table, provide the following values:

  • user_id: Enter the ID of the user you created in the previous step. This ID matches with the new admin user you added to the wp_users table.
  • meta_key: Input “wp_capabilities” as the meta key.
  • meta_value: Fill in the field with the value “a:1:{s:13:”administrator”;s:1:”1″;}.” This value assigns administrator capabilities to the new user.
After this, click on “Go” to finalize the user creation process. With this step completed, you can now log in to your WordPress site using the credentials you set up in Step 3.

Conclusion

If you find yourself locked out of your admin dashboard, don’t worry. You can still create a new WordPress admin login using phpMyAdmin to regain access to your site. Follow the step-by-step instructions outlined above to complete the new admin user account creation. If you still find any difficulty during the process, don’t hesitate to reach out to us. We are just a call away. We are available at +91-7300471483.

whatsapp logo