InMotion Hosting Support Center

When working with programs that require you to log in, such as Wordpress, there can be times when you seem to be locked out of your account. This can happen via a code error, a hack, accidental admin account deletion, or a malicious site partner changing information on you. If this happens, you will need to create a new admin account in order to regain access to the administration interface. You will need to do this by interacting directly with the database. Below is a step by step guide for doing just that in your WordPress installation.

Creating a new admin account via MySQL

The following instructions assume that your database table prefix is set to "wp_". If you are using something different, then make sure to adjust your code accordingly. For example, if you are using "wptables_" instead of "wp_", then the code "INSERT INTO `wp_users`" would be "INSERT INTO `wptables_users`".

  1. To begin, log into your cPanel interface.
  2. click the phpmyadmin iconFrom the main cPanel screen, find the Databases category and click on the icon entitled phpMyAdmin.
  3. Once the first screen appears, look to the left hand sidebar and click on the database for your specific WordPress installation. If you do not know which database is the correct one, you can find out by using these instructions.
  4. click on the SQL tabAfter the database information loads, you will need to find the tab named SQL and click on it.
  5. This leads you to an SQL editor where you will enter some code that will create a new admin account for you. Below is the code to create a new admin account named newadmin with the password pass123. You may change any of the content in red to fit your needs, but leave all other data as is.
    INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
    VALUES ('newadmin', MD5('pass123'), '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');
  6. click go buttonAfter replacing any data fields you need, click the Go button to perform the insertion.
  7. This should simply refresh the screen and you should see the messsage '1 row affected' after each of the three SQL statements. This means the insertion ran smoothly. From here, visit your wordpress admin login area as normal and use the new admin login information. You should get to the admin interface without issue.
Continued Education in Course WordPress
You are viewing Section 18: 333: How to add an admin account in WordPress via MySQL
Section 17: 331: Setting Up the Max Upload File Size for a Wordpress MS installation
Section 19: 330: Finding the Network Administrator Interface for Wordpress MS

Support Center Login

Social Media Login

   
Social Login Joomla

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
n/a Points
2014-09-28 12:57 pm

Thanks Man! This saved me time.

n/a Points
2015-04-04 11:42 pm

Thanks Man

n/a Points
2015-04-07 1:16 pm

Thank you so much for this tutorial. I'm very thankful for the help. You really saved me today.

Jen

n/a Points
2015-05-06 4:44 am

This works only if the prefix for wordpress tables is set to "wp_". Otherwise, it will fail, and result to permissions errors. As such, don't forget to set 'wp_capabilities' to whatever prefix your Wordpress installation has. For instance, if your prefix is wp_en, then your wp_capabilities should be wp_encapabilities.

Staff
25,386 Points
2015-05-06 5:55 am
Hello Rommel,

Thanks for pointing that out. The database prefix is definitely something that can be set to something OTHER than "wp_", so to anyone reading these comments and this tutorial, please be aware of that. I will update the article to make note of this issue.

Regards,
Arnel C.
n/a Points
2015-05-30 3:38 pm

This doesn't work for multisite. I tried this and after that I only see one site. Please advice.

Staff
28,219 Points
2015-06-01 11:30 am
Hello Sam,

This article is specific to regular WordPress. We have not tested this on multi-site so we do not know the specifics for it as of yet.

Kindest Regards,
Scott M
n/a Points
2015-06-25 4:19 pm

We really need to know how does this work for multisite

Staff
17,070 Points
2015-06-25 6:46 pm
Hello Sam,

Thank you for contacting us. I spent some time looking into this, and couldn't find a helpful tutorial on creating an admin in multisite. If there are other user accounts in the database, you can give a user Super Admin access.

This should allow you to regain admin access with a different user account. Then, you can create users from the dashboard again.

If your problems persist, the official Multisite Support Forums are a good place to seek help since it it is frequented by multisite users/developers.

Thank you,
John-Paul
n/a Points
2015-06-03 1:49 am

Thanks for one of the simplist how 2s on a complicated issue that i have

seen in a while

n/a Points
2015-06-24 9:16 pm

You've Helped me with this problem, a hacker who changed all accounts! Now I can tell him you are wrong hacker!

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

12 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!