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

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

Last modified: September 28, 2020

FAQ
Cloudways

More than half of small businesses are targeted by hackers. And if a criminal gets access to your website, then they can make all sorts of changes that can be problematic. One of these is that they can delete the admin account from the database, making it impossible for you to gain access to your website.

This is very problematic, but luckily there is a simple way to protect your website and add yourself back as an admin. That is to add yourself as a user using the MySQL database.

Before you attempt this, always make a backup of your MySQL database. If something really bad happens, you’ll want to reinstall the backup to protect your website.

Show More

* This button will show the rest of the post and open up an offer from a vendor

Step 1 – phpMyAdmin

The first step to this task is to go to your phpMyAdmin and locate the database for your WordPress website. Enter the database.

Step 2 – wp_users

The first thing you need to do is to click on the wp_users table. Now you need to insert the new user’s information into this area. You can do this by clicking on the ‘Insert’ tab. Then you will need to enter the following details.

ID – All users need to have a number, choose a random number for the new admin
user_login – This is the username that you want the user to be known as and use when they log into the WordPress website
user_pass – Create a strong password for the account. Remember to include at least one uppercase, lowercase, number and special character. You should also make your password at least 8 characters long. Make sure to select MD5 in the functions menu.
user_nicename – Enter in a name that you wish to be referred to on the site. This could be your real name or the name of the website.
user_email – Create the email address that will be used for the user address.
user_url – You can add in a URL for the user, this could be just your website.
user_registered – Create the date when the registration should have taken place.
user_status – Ensure this is set to 0.
display_name – This can be the same as your user_nicename or it can be something else.

When you’re finished, you can click on the ‘Go’ button.

Step 3 – wp_usermeta

Now you need to add details into the wp_usermeta table. So you need to click on that table in the phpMySQL file directory and then click on the Insert tab. Insert the following information into that field.

unmeta_id – This will be autogenerated, so leave blank.
user_id – The same number as you used on the user created in step three
meta_key – Ensure this is wp_capabilities
meta_value – Copy this out: a:1:{s:13:”administrator”;s:1:”1″;}

When you’re finished, click on the ‘Go’ button. Now you’ve created yourself a new username. You should now be able to login to your WordPress website with the username and password that you’ve created in steps two and three.

Step 4 – Clean Up

Once inside the WordPress admin section, head to the ‘Users’ section, find yourself and click to go inside. When inside, scroll down to the bottom of the page and click on save. This will tell WordPress to automatically clean up your website so it is more fluid.

Final Word: How To Add An Admin User To The WordPress Database Via MySQL

If your login details have been deleted and you can’t access the backend of WordPress any more, use the above steps to create a new user account for yourself and get the right access for your site. Once done, start using better WordPress security plugins for better protection from hacking.

Recap:
Save 4 Later
Email liked links to yourself