Learn how to add an Admin account in WordPress via MySQL
Hey Guys,
What’s Up?
Today in this article we are going to learn how to add an admin account in WordPress via MySQL. When working with CMS that require you to sign in, such as WordPress, Magento or more there may be times when your admin account is locked due to some reasons. This happens when there is a code error or someone tries to hack or by accidental admin account deletion or a malicious site partner changing information on you. If this happens, you will have to create a new super admin account in order to regain access to the WordPress backend administration. You will have to do this by interacting directly with the main database of your website. Below is a step by step guide to recover that account or create a new admin account in WordPress.
Creating a new admin account via MySQL
The following commands accept that your database table affix is set to “wp_“. If you are using someone unlike, then make sure to align your code consequently. For ex., if you are applying “wptables_” alternatively of “wp_“, then the code will be inserted into “wptables_users” at the place of “wp_users”.
Method 1.
First, you need to sign into your website cPanel interface.
Method 2.
When your cPanel is logged in then from the cPanel menu, find the “Databases” category and click on the image named “phpMyAdmin”.
Method 3.
Once the PHPMyAdmin will be opened, look at the left-hand side and click on the database which you have used for your specific WordPress website or blog installation.
Method 4.
After the extraction of the main database, you will need to detect the tab named SQL and click on it.
Method 5.
This will take you to SQL editor where you need to enter the code that will make a new Admin account for you. Below is the code to create a new admin account named “urbaneratrend” with the password “BestBlog”. Please don’t change any code, it may damage your whole database.
After this whole process, you can change your Admin details from your back-end.
Code –
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES (‘urbaneratrend’, MD5(‘BestBlog’), ‘UrbanEraTrend Admin’, ‘[email protected]’, ‘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’);
Method 6.
After substituting any data areas you need, click the Go button to execute the insertion.
Method 7.
This should merely refresh your screen and you ought to see the message “1 row affected” after each of the 3 SQL statements. This entails the insertion ran smoothly. Now you need to visit your WordPress Admin Sign in the area as a pattern and apply the new admin login information. You should acquire to the admin interface without any issue.
If you have any issues in above-given steps you may watch this video as a practical to do this.
[Video]
If you still have any questions or confusions, please let us know in the comments below. 🙂
Hope you find this method useful and share it with your friends as well. For more don’t forget to SUBSCRIBE as well.