Create a WordPress Admin Account on Server

WordPress accounts are usually created from the Dashboard, under the Users menu, but there are instances when you are not able to login to your account anymore and you are locked out of your own WP website management interface.

For instance when you:

  • don’t have access to the email account you initially used for registering your Admin WP account
  • someone else created the site for you, created the only Admin account for himself and then disappeared
  • find that your site has been hacked and your own Admin account has been deleted
  • have a malicious partner that tries taking control of your website and deletes your own account
  • … or any other circumstance when your Admin account is not accessible anymore

Provided you still have access to your hosting account it is very easy to create a new Admin account by accessing directly the database of your site.

If your hosting is using cPanel click on this icon:

and if you are using DirectAdmin click on this icon:

For both control panels the result will be the same and you’ll get the same database management interface called phpMyAdmin that will list all tables your sites in this account are using at left sidebar:

If you don’t remember the name of the database your site is using, the simplest way for finding out is to open the file named “wp-config.php” at the root folder of your site’s installation and this reference will be listed there.

Click on the required database name at the left sidebar and then on the SQL tab at the main screen and just paste in the code found here below and just press on GO at the bottom right corner of this page:

Copy-paste the following code, after replacing all entries marked in red below with your own credentials:

INSERT INTO `wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_activation_key`, `user_status`, `display_name`) 
VALUES ('11', 'adminname', MD5('password123'), 'firstname lastname', 'email@yourdomain.com', '', '0', 'displayname');

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

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, '11', 'wp_user_level', '10');

This example assumes your site’s database tables prefix is “wp_” as highlighted above in yellow. If your tables are using another prefix, just change those occurrences above in yellow with your own prefix.

NOTE: you might want to delete ‘display_name’ and its corresponding value ‘displayname’ and add this afterwards at your WP dashboard, or simply add the entry ‘user_nicename’ (=nickname) and give it an identical value as for ‘displayname”.

After clicking on the GO button, you should get a similar message that confirms everything performed correctly:

After that just login as usual to your WordPress site by using the credentials you have previously entered:

and head to your account for completing any missing information:

Your new Admin account is now fully implemented and you may continue working at your site as usual.

Share the love:

Leave a Reply