Add an admin account in WordPress via MySQL

There can be times when your WordPress admin user is hijacked or your account is locked out accidental. In such case, you may need to add a new admin user for your WordPress installation.

In this article, we will consider that you have cPanel hosting control panel. However the steps can also work for you if you have different hosting control or no control panel. You just need the interface to access your MySQL database to execute few queries.

Add an admin account in WordPress via MySQL

We will assume that your database table prefix is set to “wp_“. If you are using different database prefix, then you will need to adjust your query accordingly.

[1] First, login to your cPanel control panel.

[2] From your cPanel, go to “Databases” section and click on phpMyAdmin as shown in following image:



[3] In phpMyAdmin, click on your WordPress database name and go to “SQL” tab as shown below:

MySQL database SQL query

MySQL database SQL query

[4] In SQL query editor, execute the following three queries:

Replace new-user and your-password in the first query and then click on “Go” button.

[5] This will refresh the screen and you will see “1 row affected” after each SQL query.

You should be able to login to your WordPress admin area using the username and password which you have mentioned in step [4].

Posted in WordPress.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.