George Whitcher

Manually Add Admin User to WordPress

Manually Add Admin User to WordPress

I ran into some useful code that I thought I would share with you.  Recently I was moving some websites and I noticed all of my access had been removed (long story) and nobody could get into the WordPress admin.  With PHPMYADMIN or MySQL CLI you can just insert your own user.  With this, you will be back up and running in no time!

The below query will insert the new user.  Make sure and replace everything after “VALUES” with your relevant information.  Once inserted take note of the ID number of the newly inserted user.  You will need it for the next two steps.

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 (NULL, 'YOUR-USERNAME', MD5('YOUR-PASSWORD'), 'YOUR-NAME', 'YOUR-EMAIL', 'YOUR-DOMAIN', '2022-04-19 00:00:00', '', '0', 'YOUR-NAME');

With these two queries, we will give admin capabilities.  With the ID you got from the last query replace the “YOUR-USER-ID” field in the two below commands.

INSERT INTO 'YOUR-DATABASE-NAME'.'wp_usermeta' ('umeta_id', 'user_id', 'meta_key', 'meta_value') VALUES (NULL, 'YOUR-USER-ID', '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, 'YOUR-USER-ID', 'wp_user_level', '10');

After running those queries in PHPMYADMIN or the MySQL CLI you can log in with the information you inserted!

underpants gnomes business plan
Sharing is caring!
Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on pinterest
Share on email
Share on print