Last week, we informed an issue that some of our user’s wordpress site got hacked and their wp admin account was removed from the database. This locked them out of their site admin panel without any other entry. Then we gave them a solution to recover their admin account. We went in to the phpMyAdmin of cpanel and created a new admin user to grant them access. In this article, we will show you a step by step guide on how to create an admin user in WordPress Database via cPanel.
First, you have to login to your cpanel (www.yourdomain.com/cpanel) and locate your WordPress database by clicking phpMyAdmin (Below is a screenshot of a Namecheap cPanel)
If you are in (as above image), click on phpMyAdmin, then you will find the wp_users and wp_usermeta tables ( if you changed your database table prefix then wp is replaced by your table prefix name, ex. youtableprefix_users ). Lets go ahead and click on wp_users table.
Then click on insert tab as marked above image and you have to insert your new admin user’s information. In the insert form, add the following information:
Informations for wp_users
- ID – pick a unique number (ex. 21).
- user_login – insert the username by which you want to use to access the WP dashboard.
- user_pass – Create a strong password ( letter, number, special character ) for this username. Make sure that you select MD5 in the functions menu.
- user_nicename – put a nickname as you want.
- user_email – add an email which will associate with this account.
- user_url – this would be the url of current your website.
- user_registered – select the date/time for when this user is registered.
- user_status – set this to 0.
- display_name – put a name you like to display for this user on your site (you can also set this letter).
- Finally click on the Go Button
Next you have to add the values to wp_usermeta table. Click on the wp_usermeta tab and then click on the Insert tab just like the previous step. Then add the following information to the insert form:
Informations for wp_usermeta
- unmeta_id – leave this blank (it will be auto-generated)
- user_id – this is the id of the user that you created in the previous step. ( previous step we created id 21)
- meta_key – this should be wp_capabilities ( replace wp with your database table prefix )
- meta_value – insert this to give the user as administrator role:
Insert another row with the following information to complete admin user:
- unmeta_id – leave this blank as previous (it will be auto-generated)
- user_id – this is the id of the user that you created in the previous step. ( ex. 21)
- meta_key – this should be wp_user_level ( replace wp with you database table prefix )
- meta_value – 10 ( to give the user at top level )
Then click on the Go button, and you have created yourself a new admin user. Now login to your wordpress admin dashboard ( www.yourdomain.com/wp-admin ) with the username and password that you’ve specified for this user. Once logged in, click on Users and edit the username you just created. Now you should go to the user tab on wp dashboard and check the users of your site. Remove the users who are inactive on your site and keep your wordpress site secure ( Read how can keep wordpress site secure )
You can tell us your any problem or query for your site by commenting here. We’ll try to give you a better solution as soon as possible.