Hello guys today we will learn how to add an Administrator from WordPress MySQL Database in this tutorial article. Actually yesterday my best friend told me that his WordPress website was hacked and her account has been deleted. He asked me what’s the solution how to add new Administrator without accessing WordPress dashboard. So, I gave her satisfying solution that you can add administrator from MySQL.
NOTE: Before we start doing this, make sure that you have taken backup of your website Database.
Add an Administrator from WordPress MySQL Database
Below are the two ways to perform this task, not to worry I’ll tell you both:
- Run a MySQL query
- Do it all steps manual in WordPress MySQL Database
1. Run a MySQL query
This method is only for those who want to speed up the process. In this process, we have to make sure to change following things:
- Table prefix( if you are Database table prefix is different ).
- Database name
- Values( like ID, username)
INSERT INTO 'your-database-name'.'wp_users' ('ID', 'user_login', 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'user_activation_key', 'user_status', 'display_name') VALUES ('84', 'username', MD5('your-password'), 'Your Name', '[email protected]', 'http://www.google.com/', '2017-09-08 16:15:25', '', '0', 'Your Name'); INSERT INTO 'your-database-name'.'wp_usermeta' ('umeta_id', 'user_id', 'meta_key', 'meta_value') VALUES (NULL, '84', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}'); INSERT INTO 'your-database-name'.'wp_usermeta' ('umeta_id', 'user_id', 'meta_key', 'meta_value') VALUES (NULL, '84', 'wp_user_level', '10');
Now open the wp-admin, log in with username and password you specified for this user. Once you logged in click on Users tab from left sidebar in the dashboard and edit the username you just created. Scroll down and just click the Save/Update button(no need to change anything, just click on save button). This process will allow WordPress to go through and add some more information and clean-up the user we just added.
2. Manual Steps in MySQL
First, you need to Login to your hosting cPanel and access phpMyAdmin and find your WordPress MySQL database, See below screenshots(Source: Godaddy cPanel).
Once you open your WordPress database, we are going to make changes in two tables, one is wp_users and the second one is wp_usermeta. Let us start with the first table wp_users, just click on the table name. We need to insert our new Administrator. Let’s click on insert tab, see below
Once you clicked on insert tab, you have to fill below fields.
- ID: Leave it blank it is an auto-increment field. Its value will be filled automatically.
- user_login: Insert the username from which you access the WordPress dashboard.
- user_pass: Add strong password for the username and make sure that to select MD5 in the function drop-down menu.
- user_nickname: Add your nickname
- user_email: Add your email address to blend with this account.
- user_url: You can add your website URL here.
- user_registered: Here you can select date/time when user registering.
- user_status: By default set as 0.
- display_name: Add your name you wish to display
After all that click on GO button. see below
After inserting the user/admin information in the wp_users table, now we are going to add the value in the wp_usermeta table. Here we follow same steps, just click on table name(wp_usermeta) and again click on insert tab.
Now add following information in the Insert tab:
- unmeta_id: Leave this field blank, it’s auto-generated.
- user_id: In this field, you have to add the ID of the user you created in the wp_users table.
- meta_key: Insert this wp_capabilities
- meta_value: Insert this a:1:{s:13:”administrator”;b:1;}
We have to add few more information in another row:
- unmeta_id: Leave this field blank, it’s auto-generated.
- user_id: again ID of the user you created in the wp_users table.
- meta_key: Insert this wp_user_level
- meta_value: 10
After all, Hit the GO button and you are now admin of the website. Now open the wp-admin, log in with username and password you specified for this user. Once you logged in, click on Users tab from left sidebar in the dashboard and edit the username you just created. Scroll down and just click the Save/Update button(no need to change anything, just click on save button). This process will allow WordPress to go through and add some more information and clean-up the user we just added.
23 Comments
Vikas Pundora
very nice and helpful article…
Anibal Cuneo
Hi! Do you know if they make any plugins to safeguard against hackers? I’m kinda paranoid about losing everything I’ve worked hard on. Any tips?
phpyouth
yes, you can use the Sucuri plugin to secure your website from hackers, Very powerful plugin.
minecraft
Thanks , I have recently been searching for info approximately this
subject for a long time and yours is the greatest I’ve discovered till now.
But, what about the bottom line? Are you sure
concerning the supply?
phpyouth
Not Understand what you said, can you please clarify…
http://tinyurl.com
It’s actually a great and helpful piece of information. I
am satisfied that you simply shared this helpful info with us.
Please stay us up to date like this. Thank you for sharing.
phpyouth
Thank you so much, keep learning and sharing
Zoe
Thank you for the terrific post
phpyouth
Thank you so much, Zoe keep learning and sharing
minecraft
Hello there, You have done an excellent job. I’ll definitely digg it and
personally suggest to my friends. I am sure they’ll be benefited from
this web site.
phpyouth
Thank you so much, Keep learning and sharing
authentic jordans
Thank you for all your valuable effort on this website. My mother really loves carrying out investigations and it is easy to understand why. A lot of people hear all regarding the powerful way you provide simple guides by means of your blog and therefore attract contribution from people on this subject matter and our own girl is understanding a lot of things. Enjoy the rest of the year. You are always doing a good job.
phpyouth
Thank you so much, keep learning and sharing
nike air max 2018
Thank you for all of your work on this website. My mom takes pleasure in making time for internet research and it is easy to understand why. My spouse and i know all relating to the powerful mode you give very important tips through your website and even strongly encourage participation from other individuals on that matter and our favorite simple princess is without question discovering a great deal. Have fun with the remaining portion of the new year. You are always conducting a terrific job.
phpyouth
Thank you so much, keep learning and sharing.
authentic jordans
I would like to express some thanks to you for bailing me out of this particular problem. Because of scouting through the the web and obtaining thoughts that were not pleasant, I figured my entire life was done. Being alive minus the strategies to the difficulties you’ve sorted out by means of your entire write-up is a crucial case, and the kind which may have in a negative way affected my entire career if I had not discovered your web blog. Your main training and kindness in handling the whole lot was important. I am not sure what I would’ve done if I hadn’t encountered such a thing like this. I am able to at this point look ahead to my future. Thank you so much for the impressive and results-oriented help. I won’t be reluctant to endorse the website to any individual who should receive guidelines about this topic.
phpyouth
Thank you
tinyurl.com
Ahaa, its good discussion regarding this paragraph at this place at this webpage, I have read all that,
so at this time me also commenting here.
phpyouth
Thanks you Tinyurl
minecraft
I blog frequently and I seriously thank you for your content.
Your article has truly peaked my interest. I’m going to book mark
your blog and keep checking for new details about once per
week. I opted in for your RSS feed too.
phpyouth
Thanks for your interest, keep learning
minecraft
I’m extremely inspired with your writing abilities and
also with the layout on your weblog. Is this a
paid subject or did you customize it your self?
Anyway keep up the excellent high quality writing, it is
uncommon to see a nice blog like this one nowadays..
phpyouth
Yeah, designed myself. Thanks