If you have been locked out of your WordPress admin dashboard — due to a forgotten password, a deleted account, or a plugin conflict — you can regain access by creating a new administrator user directly in the database via phpMyAdmin.

Step 1: Open phpMyAdmin

  1. Log in to your cPanel account.
  2. Navigate to the Databases section and click phpMyAdmin.

Step 2: Select Your WordPress Database

Click your WordPress database in the left sidebar. All WordPress tables will appear. Look for tables prefixed with your database prefix (default: wp_).

Step 3: Insert a New User in the wp_users Table

  1. Click the wp_users table.
  2. Click the Insert tab at the top.
  3. Fill in the fields as follows:
  • ID — Pick a unique number not used by existing users.
  • user_login — The username for logging in.
  • user_pass — Enter your desired password. Important: In the Function column for this field, select MD5 from the dropdown. WordPress will automatically upgrade the hash to its native phpass format when you first log in.
  • user_nicename — The user's full name or nickname.
  • user_email — A valid email address.
  • user_url — Your website URL (e.g., https://yoursite.com).
  • user_registered — Use the date/time picker or leave the default.
  • user_activation_key — Leave blank.
  • user_status — Set to 0.
  • display_name — The name displayed on the site.

Click Go to save the new user record. Note the ID value you used — you will need it in the next step.

Step 4: Assign Administrator Capabilities in wp_usermeta

  1. Click the wp_usermeta table.
  2. Click the Insert tab.
  3. Fill in the fields:
  • umeta_id — Leave blank (auto-generated).
  • user_id — Enter the ID from Step 3.
  • meta_key — Enter wp_capabilities (or your custom prefix + capabilities).
  • meta_value — Enter the following serialized value:
    a:1:{s:13:"administrator";s:1:"1";}

Click Go to insert the row.

Step 5: Set the User Level (Required by Some Plugins)

  1. Still in wp_usermeta, click Insert again.
  2. Fill in:
  • user_id — Same user ID from Step 3.
  • meta_keywp_user_level
  • meta_value10

Click Go.

Step 6: Log In to WordPress

Navigate to https://yoursite.com/wp-login.php and log in with the new username and password. Once logged in, you can manage other users, reset passwords, or investigate what caused the lockout.

Important Notes

  • Always back up your database before making manual changes. In cPanel, go to Databases → Backups or use phpMyAdmin → Export.
  • Some installations use a custom database table prefix (e.g., abc_ instead of wp_). Adjust wp_users, wp_usermeta, wp_capabilities, and wp_user_level accordingly. Check the table_prefix value in your wp-config.php file if unsure.
  • WordPress automatically converts the MD5 password hash to a secure phpass hash on first successful login.
  • Delete the temporary admin account once you have regained access to your original account.

Troubleshooting

  • "Access denied" or blank page after login: Clear your browser cache and cookies, then try again.
  • Cannot find wp_users table: Your database uses a custom prefix. Check wp-config.php for the $table_prefix value.
  • User appears but has no admin privileges: Verify the wp_capabilities meta_key was inserted with the correct user_id and serialized value. A common mistake is a typo in the serialized string.
  • Still locked out: The issue may be caused by a security plugin (e.g., Wordfence, iThemes Security). Try temporarily renaming the plugin's folder via cPanel → File Manager to disable it.
Was this answer helpful? 0 Users Found This Useful (0 Votes)