How to create an admin account in WordPress via MySQL

If you experience an issue in which your administrator account is blocked from accessing the WordPress dashboard, one way to resolve the problem is to create a new administrator account. As you are unable to do this from the dashboard, the alternative is to manually create the account in your WordPress database.

Log in to the HostPapa Dashboard and click My cPanel from the top navigation menu. Select phpMyAdmin from the Databases section of the cPanel menu.

cPanel

Select your WordPress database from the list presented in the left sidebar.

phpMyAdmin

In the right pane, click the SQL button.

SQL tab

Enter the following code in the box labelled Run SQL query/queries on database. This code creates a new administrator account with the following credentials:

  • User name: admin999
  • Password: password999

Change these credentials in the code to your own selection.

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, 
`user_status`)
 VALUES ('admin999', MD5('password999'), 'firstname lastname', 'email@example.com', '0');
 
 INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
 VALUES (NULL, (Select max(id) FROM wp_users), 
 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
 
 INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
 VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');

SQL query

Click the Go button to run the query.

Now head to the WordPress administration dashboard and try to log in with the newly created credentials.

If you notice any problems or if you need any help, please open a new support ticket from your HostPapa Dashboard. More details on how to open a support ticket can be found here.

Was this article helpful?

[was-this-helpful]

Related Articles

Leave A Comment?