With programs such as WordPress, you need a login name to enter the administrative area. This is initially created during the installation of the program. However, there can be times when the admin account gets corrupted ore deleted by various means. In cases like this, you will need to add a new admin account to the database in order to be able to log in again. This cannot be done during normal means and will require that you do so by inserting the information into the database itself. Follow the guide below as we explain how to create a new admin account with SQL via the phpMyAdmin tool.
How to add an new admin account with SQL
- First, log into your cPanel dashboard.
- Once you are on the main cpanel page, locate the Databases category. From there, click on the icon entitled phpMyAdmin.
- This takes you to the phpMyAdmin main area. From the database menu in the left hand sidebar, find and click on your specific database for the installation you are working with. Follow these instructions to find out what database is the correct one if you do not know.
- Now that the information is loaded, you will need to find the tab named SQL from across the top of the page and click on it.
- Next, you will need to enter the code to create the new admin account. The code below will create a new admin account with the username admin2 with the password newpass. The data that is colored in blue is meant for you to customize, but leave all the other code as it is written. Be sure to remember on the username and password you enter for your login.
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('admin2', MD5('newpass'), 'firstname lastname', '
This email address is being protected from spambots. You need JavaScript enabled to view it.
', '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');
- Once your personal data is entered, click the Go button so the new row will be added.
- If you do not receive an error message, the data was inserted correctly. Now you can visit your wordpress admin login area using your new admin login information.
We value your feedback!
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
new! - Enter your name and email address above and we will post your feedback in the comments on this page!