Manually Add a WordPress User with Administrator Role to the MySQL Database using SQL Quries or phpMyAdmin
In a recent WordPress hack attack which we worked on and recovered, the owner’s WordPress administrator account was demoted to a user role, therefore the owner did not have any control over the WordPress installation. To regain back access to WordPress, we manually created a new WordPress user with an Administrator role directly in the database.
In this tutorial we will show you how to manually create a WordPress administrator in the WordPress database by using any MySQL command line (SQL queries).
Create a WordPress User using SQL Queries
Or as frequently referred to, MySQL Command Line
If you have access to your MySQL database server via command line, you can use the below SQL queries to create a new WordPress administrator in the database.
The above SQL SQL queries will create a new WordPress administrators with the following details:
- User Id: 1000
- Username: tempuser
- Password: Str0ngPa55!
- Email: email@example.com
Before using the above MySQL queries do not forget to:
- change the wordpressdatabase to the WordPress database you are working with
- change the default table prefix (wp_) if the WordPress database you are working with have non default prefixes
- change the user Id to a bigger number if you have created more than 1000 WordPress users (If you do not specify a user ID it will be automatically generated. Then retrieve the record using an SELECT SQL statement).
Once the above SQL queries are executed, you can login to your WordPress blog or website with the newly created WordPress administrator account.