Create WordPress Admin Account in Database using phpMyAdmin
Accidentally delete the admin account from your WordPress website? No, worries, we will show you how you can add a new user with admin privileges in the Database of WordPress Website. For this, we will use phpMyAdmin which has simple UI and most of the users are familiar with it.
Requirements
- phpMyAdmin access in cPanel or any control panel.
- Database Name, User and Password
Procedure
- Login to your Control panel and open phpMyAdmin.
- Some panels automatically login to the virtual user and open the DB list and some require DB credentials.
- After phpMyAdmin Login and select the Database of the website. It will show a couple of tables from the database.
- Click on SQL Tab and paste the following query.
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('newadmin', MD5('passwordhere'), 'Firstname LastName', 'emailid@domain.com', '0');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');
Note: Edit the text in bold as per your requirement. Cross-check the table prefix. In our case, it is wp_ and might differ from WordPress Installation. Find DB prefix in the wp-config.php file present in your website’s root directory. If the prefix is not wp_ then kindly update the above 3 SQL Statements accordingly.
- After pasting the query in SQL press the Go Button. It will take a few seconds to execute and will show the ‘1 row affected’ after each of the three SQL statements as the following image.
- Now you can try logging in with the user created. It should have the admin permissions.