Lets suppose you are about to work in an existing WordPress website, and the client only gives you the cPanel details. How would you get into the WordPress backend? You could obviously ask your client to create an admin user for you. But wouldn’t it be cool if you could just create an admin access right from the database?
You might need to create logins directly from the database for many reasons. Your website might be recently hacked and the hacker deleted you from the administrator list. Whatever be the reason, it is always quicker to create user through database rather than the dashboard itself.
Okay enough talking, lets start the tutorial.
1. Login to your cPanel and locate phpmyadmin. Locate your database and go to wp_users table.
2. Open wp_users table and Click Insert at the top
3. Enter username, password (MD5) and email address and click on go!
Please not that you don’t need to enter any values in ID as it is auto assigned. Also select MD5 option on user_pass field before entering your password, this lets you save password as a text which is encrypted later on.
4. Find the user you just created in the wp_users table and note the user ID, you will need it.
Here in this example user ID is 2.
5. Go to wp_usermeta table and click insert
6. Enter the following information to assign administration capabilities.
user_id: Enter the user ID you previously remembered.
Note: replace wp_ with your table prefix if you need to. See how your tables are named. If its named abc_users, then use abc_capabilities. I hope you get it! Once you enter all the data, click on GO.
7. On the same wp_usermeta table, click insert again, and enter the following values:
user_id: Same user ID
Click on “Go”. And boom, you have now created admin user right from the database. Isn’t that cool. Please comment down if you need any help.