Locked Out of the WordPress Admin? Here's How to Regain Access

7 min read Auf Deutsch lesen

Can’t get into the WordPress backend anymore? No need to panic – in the vast majority of cases you’ll be back in within minutes. Which route fits depends on what you still have access to. We’ll go from the simplest to the most involved.

Caution: always make a backup before working directly on your database.

1. “Lost Your Password” on the Login Page

Sounds simple, and often is. The “Lost your password” link on https://www.domain.tld/wp-login.php is frequently enough to get back in – provided you can access the registered email address. If that doesn’t work, it’s usually the site’s email delivery, not the access itself – then the next routes come into play.

2. You Have Access to phpMyAdmin

Log into phpMyAdmin, pick your database and open the wp_users table (the wp_ prefix may differ for you – see $table_prefix in wp-config.php).

Just change the password: edit your user, enter a new password and select MD5 as the encryption before saving. WordPress accepts this and re-hardens the password on first login.

Create a new admin: if you’d rather make a fresh administrator, use the generator below and run the SQL under the “SQL” tab.

3. No phpMyAdmin, but FTP Access

Then create the user via your active theme’s functions.php (path: /wp-content/themes/themename/). Pick the functions.php tab in the generator, paste the block, load your site once – and remove the code again afterwards, so the user isn’t created on every request.

Generator: SQL or functions.php Snippet

Admin User Generator

Create a new administrator

For your own site when you're locked out. Fill in your details, copy the right snippet – everything stays in your browser.

Your input never leaves the browser. Snippets are generated locally via JavaScript.

Already have a user, just forgot the password? If you know the user ID, this in functions.php is enough:

wp_set_password( 'new-password', 1 ); // 1 = user ID

If you only ever created one user, it almost certainly has ID 1. Remove the code afterwards.

4. PHP Script: Upload Once, Run Once, Done

Have FTP access but would rather skip phpMyAdmin and functions.php fiddling? This is your route: a PHP script you upload to the WordPress root, open in your browser once – and it deletes itself automatically afterwards.

Script Generator

PHP Script to Upload

Fill in credentials → download script → upload via FTP to WordPress root → open in browser. Deletes itself afterwards.

How to use:

  1. Download the script (button above)
  2. Upload via FTP/SFTP to your WordPress root – same level as wp-config.php
  3. Open in browser: https://your-domain.tld/wp-recovery.php
  4. Log in with the new credentials – the file deletes itself automatically

Your input never leaves the browser. The script is generated locally via JavaScript.

5. No Access to the Webspace or phpMyAdmin at All

Then the fix starts at the hosting level. Through your hosting panel you can reset the (s)FTP credentials and get back onto the webspace. If you can’t access that either, use your hosting account’s “forgot password” function or simply call your host. Once hosting access is restored, all the routes above are open to you.

Which Database Is the Right One?

If there are several databases, just look in the wp-config.php in your install’s root directory. Find the line:

define( 'DB_NAME', 'db1234' );

The value is the name of your WordPress database.

Afterwards: Secure the Login

Once you’re back in, it’s worth learning from the incident. A cleanly set, unique password and two-factor authentication keep you from locking yourself out again and keep attackers out at the same time – see Securing the WordPress Login. If the lockout came as a surprise, check to be safe whether the site was compromised.


If none of the routes work, or you’d rather not touch the database and code directly: drop us a line – we’ll get you back into the admin.

Frequently Asked Questions

Isn't MD5 insecure?

For storing passwords, yes – which is why WordPress no longer uses it permanently. On first login, WordPress automatically converts the MD5 password into its secure hash. For a one-off recovery, the route is fine.

My prefix isn't wp_ – what now?

Enter your actual prefix in the generator. You'll find it in wp-config.php under the table_prefix entry.

I can't even reach the login.

Then access may not be the problem – the site itself is throwing an error. Find the right starting point in the overview of causes for a missing backend.

How do I create a new admin user when I'm locked out?

The easiest way is the generator on this page: it produces either an SQL snippet for phpMyAdmin or a block for your theme's functions.php. Both create a fresh administrator you can log in with immediately. Important: remove the functions.php block after the one-off run, so the user isn't recreated on every page load.

Daniel Nilges
Daniel Nilges

Founder & Full-Stack Developer

20+ years of web development experience. Specialised in Laravel, WordPress and custom software for mid-sized businesses.