Updated on 28 January, 2026 by Robert Abela
How to Manually Add a WordPress Administrator to the Database using SQL Queries
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 of the following methods; MySQL command line (SQL queries), or via phpMyAdmin.
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.
INSERT INTO `wordpressdatabase`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`, `display_name`)
VALUES ('1000', 'tempuser', MD5('Str0ngPa55!'), 'tempuser', '[email protected]', '0', 'Temp User');
INSERT INTO `wordpressdatabase`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, '1000', 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');
INSERT INTO `wordpressdatabase`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, '1000', 'wp_user_level', '10');
The above SQL SQL queries will create a new WordPress administrators with the following details:
- User Id: 1000
- Username: tempuser
- Password: Str0ngPa55!
- Email: [email protected]
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 prefix of the entries wp_capabilities and wp_user_level if you have configured 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.
Create WordPress Administrator with phpMyAdmin
To create a new WordPress user with an administrator role directly in the database using the web based phpMyAdmin, first login to phpMyAdmin and click the WordPress database. Then:
Modify the wp_users Table
- Click on wp_users table and click the Insert tab as seen in the below screenshot.

- Populate the temp administrator information as seen in the above screenshot, mainly:
- ID: 1000 (You can pick any number. We choose 1000 in case the WordPress installation already contains a lot of users)
- user_login: tempuser (the username used to login to WordPress)
- user_pass: Str0ngPa55! (The user password. Make sure you select MD5 from the functions drop down menu)
- user_nicename: temp user (The nickname required by WordPress)
- user_email: [email protected] (The user’s email address required by WordPress)
- user_registered: configure it to the current date
- user_status: 0
- display_name: Temp User (The display name for the user, i.e. how other users will see it).
- Once ready click the Go button to insert the values into the database.
Modify the wp_usermeta Table
- Click on wp_usermeta table and click the Insert tab as seen in the below screenshot.

- Populate the fields with the below details as seen in the above screenshot:
- umeta_id: leave this blank (value will be auto generated)
- user_id: the user ID of the user you created in the previous step. In our example we used 1000.
- Meta_key: wp_capabilities
- meta_value: a:1:{s:13:”administrator”;b:1;}
- Once ready click the Go button to insert the values into the database.
- Create another row by clicking again the Insert tab and populate the fields with the below details, as seen in the below screenshot:
- umeta_id: leave this blank (value will be auto generated)
- user_id: the user ID of the user you created in the previous step. In our example we used 1000.
- Meta_key: wp_user_level
- meta_value: 10

- Once ready click the Go button to insert the values into the database.
The new WordPress user with administrator role is created so proceed to login to your WordPress blog or website using the newly created account.
Melapress Tip: Use the newly created user until you fix your issues and regain access to the previous account. Delete it once ready. We recommend you to create a new WordPress administrator account using a strong username and a strong password.
