How to manually add an admin user to WordPress

Posted on June 27, 2013 @ 2:58 am

Tags: , ,

No Comments

Last updated on December 26th, 2015 at 10:26 pm

Use MySQL and phpMyAdmin to add an admin user to WP

There are times that you have been locked out from WP Admin Dashboard like for example if you get hacked or if your WP update didn't complete as normal.

Fortunately there is a shortcut for creating a new WP Admin user using the phpMyAdmin tool(should be located inside your hosting cpanel account) in order to access and edit your WP MySQL DB tables.

First thing to do when you get into your DB and select the SQL tab which is located on the top of the page(see screenshot below)

phpmyadmin sql tab

Then copy and paste the following query making sure to replace "testuser", "testpassword", "Fix My WP", "[email protected]", "Fix My WP" and "https://fixmywp.com" with your desired username, user password, user nice name, user email, user url and display name.

INSERT INTO `wp_users`
(`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`,
`user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`)
VALUES ('999', 'testuser', MD5('testpassword'), 'Fix My WP', '[email protected]',
'http://www.fixmywp.com/', '2013-06-27 00:00:00', '', '0', 'Fix My WP');

and select "Go"

run sql query on phpmyadmin

Repeat this last step for the following queries as well:

INSERT INTO `wp_usermeta`
(`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, '999', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `wp_usermeta`
(`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, '999', 'wp_user_level', '10');

and when done reload your wp-admin page and try to log in using your new admin user details.

Makis Mourelatos

WordPress Security Engineer at FixMyWP
WC Athens 2016 co-organizer, WP Support and Security Aficionado, Wannabe Kitesurfer.

Leave a Reply

Your email address will not be published. Required fields are marked *