WP Tuts Hub

Browse

  • Home
  • Categories
    • WordPress & AI
    • WordPress Security
    • WordPress Troubleshooting
    • WordPress Tips and Tricks
    • SSH (Secure Shell)
    • WordPress Insights
    • WordPress Common Facts
  • Series Tutorials
  • My Plugins
  • Contact Me
  • About WP Tuts Hub
Home/WordPress Tips and Tricks/How to Create a WordPress Admin User via MySQL (phpMyAdmin)
WordPress Tips and Tricks
By Md. Zubaer Ahammed Updated November 10, 2026

How to Create a WordPress Admin User via MySQL (phpMyAdmin)

  • WordPress Administrator
  • WordPress Tips
  • WordPress Tricks

Locked out of WordPress with no working administrator account? If you can still reach the database, you can create a new administrator directly in MySQL. This guide shows the quickest SQL method, the phpMyAdmin method, and the mistakes that most often leave the new user without admin rights.

Note These steps were checked on WordPress 7.1.3 with PHP 8.2 in November 2026.

From experience · Md. Zubaer Ahammed

A client once asked me to get them back into their own site. They had forgotten the admin password, and the site could not send email, so a password reset was impossible. Creating a new admin user directly in the database was the only way in.

Before you start

  • Take a database backup first. You are editing user tables directly.
  • Find your table prefix. Open wp-config.php and look for $table_prefix. It is wp_ by default, but many sites use something else, such as wpi_ or wp7x_. Every table and meta key below must use your prefix.
  • If you have SSH access, try WP-CLI first. It is safer than editing tables by hand (see the next section).

The easiest way: WP-CLI

If WP-CLI is installed on the server, one command creates a proper administrator with a correctly hashed password:

wp user create rescue_admin [email protected] --role=administrator --user_pass='a-long-unique-password'

If you only need a new password for an existing administrator, update that account instead of creating another:

wp user update existing_admin --user_pass='a-long-unique-password'

If you do not have WP-CLI, use one of the SQL methods below.

Advertisement

Step 1 Run the SQL to create the user

Open phpMyAdmin (or Adminer, or the mysql command line), select your WordPress database and open the SQL tab. Replace wp_ with your table prefix in all three statements, then change the username, password and email:

INSERT INTO wp_users (user_login, user_pass, user_nicename, user_email, user_registered, user_status, display_name)
VALUES ('rescue_admin', MD5('a-long-unique-password'), 'rescue_admin', '[email protected]', NOW(), 0, 'Rescue Admin');

SET @uid = LAST_INSERT_ID();

INSERT INTO wp_usermeta (user_id, meta_key, meta_value) VALUES
(@uid, 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}'),
(@uid, 'wp_user_level', '10');

Run all three statements together, so LAST_INSERT_ID() still holds the new user’s ID.

Important Both meta keys start with your table prefix too. On a site whose prefix is wpi_, they must be wpi_capabilities and wpi_user_level. With the wrong prefix the user can log in but has no role, so the dashboard shows “Sorry, you are not allowed to access this page.”

Why MD5 is safe to use here

WordPress has not stored passwords as MD5 for many years, and since WordPress 6.8 it uses bcrypt. It still accepts an old MD5 hash once, so emergency fixes like this one keep working. In our test on WordPress 7.1.3, the MD5 value inserted above was accepted, and on the first successful login WordPress replaced it with a bcrypt hash starting with $wp$2y$. You do not need to do anything else, but do log in straight away so the weak hash is replaced.

Step 2 Or do it through the phpMyAdmin forms

If you prefer the forms to SQL, the same values go in through Insert:

  1. Open the wp_users table (with your prefix) and click Insert.
  2. Leave ID empty. Fill in user_login, user_email, user_nicename and display_name. Set user_status to 0 and user_registered to the current date and time.
  3. For user_pass, type the password and choose MD5 in the Function column. Click Go, then note the new user’s ID.
  4. Open the wp_usermeta table and insert two rows for that user_id:
    • meta_key wp_capabilities, meta_value a:1:{s:13:"administrator";b:1;}
    • meta_key wp_user_level, meta_value 10

Tip Older tutorials, including the first version of this one, use a:1:{s:13:"administrator";s:1:"1";} for the capabilities value. That still works. The b:1 form above is what WordPress itself writes.

Step 3 Log in and tidy up

  1. Go to /wp-login.php and log in with the new account.
  2. Open Users › Profile, check the details and click Update Profile. This lets WordPress fill in any fields you left empty.
  3. Fix the original problem: reset the password of your normal account, or remove an account you no longer trust.
  4. When you are back in, delete the rescue account or give it a strong password and two-factor authentication. Do not leave a spare administrator lying around.

Note If a security plugin such as Wordfence adds a CAPTCHA or two-factor check to the login form, it still applies to the new account. Complete it as usual.

Troubleshooting

  • “Sorry, you are not allowed to access this page”: the capabilities row is missing or uses the wrong prefix. Check SELECT * FROM wp_usermeta WHERE user_id = 123; (with your prefix and the new user’s ID).
  • Login says the password is incorrect: make sure MD5 was applied to the password, and that the value in user_pass is 32 characters long, not the plain password.
  • Duplicate entry error: the username or email already exists. Pick another, or reset that user’s password instead.
  • Multisite: a network super admin is also listed in the site_admins row of the wp_sitemeta table. Creating the user as above only makes them an administrator of the main site.

When you should not do this

If you did not lose access yourself, an unknown administrator or missing account can be a sign the site was hacked. Creating another admin will not fix that. Check the users list for accounts you do not recognise, change all passwords and your database password, and scan the site before you carry on.

My tip · Md. Zubaer Ahammed

The same trick is also a threat: anyone with access to your database or files can create an admin account this way, and a hidden admin account is a classic backdoor.

Conclusion

With database access, three SQL statements give you a working WordPress administrator again: one row in wp_users and two rows in wp_usermeta, all using your table prefix. Log in straight away so WordPress upgrades the password hash, then remove the rescue account once you have fixed the original problem.

Official reference Resetting your password · wp user create · wp-config.php

Share this:

  • Share on X (Opens in new window) X
  • Share on Facebook (Opens in new window) Facebook
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Reddit (Opens in new window) Reddit
  • Email a link to a friend (Opens in new window) Email

Related

Advertisement
Previous Article How to Fix the HTTP Error When Uploading Images in WordPress
Next Article SSH Commands Cheat Sheet for WordPress Developers (2026)

About the author

Md. Zubaer Ahammed

Md. Zubaer Ahammed

Md. Zubaer Ahammed is a senior full-stack developer building learning platforms and modern web systems with WordPress, Laravel, Python/Django, Vue, and React. More at https://zubaer.com/.

I also build WordPress plugins, including ZubFeat AI Featured Image and ZubQuant. See my plugins and services →

Related Posts

  • Fix WordPress Critical Error After Update Fix WordPress Critical Error After Update
  • Fix WordPress Memory Exhausted Error Fix WordPress Memory Exhausted Error

Leave a Reply

Cancel reply

WP Tuts Hub

WordPress tutorials, themes, and plugins — written for builders.

Topics

  • WordPress & AI
  • WordPress Security
  • WordPress Development
  • WordPress Troubleshooting
  • WordPress Tips and Tricks

Resources

  • My Plugins
  • Portfolio
  • About WP Tuts Hub
  • Contact Me

© 2026 WP Tuts Hub · Md. Zubaer Ahammed

Privacy Policy Terms of Use