🚀 Is building a website too difficult? Let me guide you step by step—Learn about the 「Naibabiji WordPress Website Building Coaching Service」 →

What to Do If You Forget Your WordPress Password? 4 Methods to Quickly Recover Your Admin Password (2026 Latest)

WordPress forgot passwordis a common issue faced by website owners. When you cannot recover it via email, the admin password is invalid, orunable to log in to the WordPress admin dashboardthe4 password reset methodsprovided in this article can help you quickly regain access:

  • PHP reset script- Suitable for users with server file management permissions, completed in 5 minutes
  • Direct database modification- Reset password by executing SQL commands via phpMyAdmin
  • functions.php modification- Use FTP to upload code to temporarily create a new administrator
  • One-click modification via server control panel- Suitable for users using WordPress hosting (e.g.,SiteGroundHostingeretc.)

Whether you are aWordPress beginneror have some technical foundation, you can find a suitablePassword Recovery Solution. It is recommended to try Method 1 first, as it is simple and secure.

Method 1: Use a reset script to recover (Recommended)

Applicable Scenarios:Users who can upload files to the server. (This can be done via Baota Panel, FTP, or the server's file manager.)

Operation Steps:

1. Download the reset script and upload it to the server.

2. Access the reset script via your domain + czjb.php?key=blog.naibabiji.com.

URL Example: https://www.baidu.com/czjb.php?key=blog.naibabiji.com

3. Follow the prompts to modify the username and password. After a successful reset, the script will automatically delete the czjb.php file to ensure security.

4. Log in to the Admin Dashboard using the modified password. The administrator password recovery is now complete.

WordPress管理员账户恢复工具

Method 2: Change password via the database

Applicable Scenarios:Users who know their server database information and can log in to the database via phpMyAdmin.

If you remember the database password, you can directly log in to the database via phpMyAdmin to make the changes. The specific steps are as follows:

  1. Log in to phpMyAdmin (or other database management software)
  2. Enter your website's databasewp_userstable.
  3. Find the row corresponding to the account you need to modify.
  4. Double-clickuser_passthe value in that row and replace the content with06a5ac9504e3a3c83574cf7a6479be2d
  5. Log in to the website again; the password has been changed tohao123
phpmyadmin数据库

Method 3: Reset admin password via functions.php

Applicable Scenarios

  • Unable to retrieve password via email
  • Know the administrator username but have forgotten the password
  • Have FTP or file manager access permissions

If you remember your website's FTP information, you can use FTP software to modify the functions.php file in the Theme folder to change the password.

1. Use FTP software to download the functions.php file from the currently active Theme folder to your local machine.

2. Edit the functions.php file and insert the following code at the very end

// WordPress管理员密码重置 - 执行后请立即删除此代码
add_action('init', 'reset_admin_password');
function reset_admin_password() {
    $username = '你的管理员用户名';  // 修改为你的管理员用户名
    $new_password = 'NewPass123!';   // 修改为新密码
    $user = get_user_by('login', $username);
    if ($user) {
        wp_set_password($new_password, $user->ID);
        echo "密码重置成功!
"; echo "用户名: " . $username . "
"; echo "新密码: " . $new_password . "
"; echo "请立即登录后台删除此代码!"; } else { echo "错误:找不到用户 '" . $username . "'"; } exit; }
WordPress重置管理员密码脚本

3. Upload the functions.php file to the Theme directory, overwriting the original file.

4. Visit the website; you will be prompted that the password has been successfully changed.

5. Download the functions.php file to your local machine, delete the added code, and upload it again to the Theme directory.

Method 4: One-click modification via the server control panel

Applicable Scenarios:

The server uses specialized hosting like SiteGround and Hostinger that support one-click WordPress installation from the backend. Enter the server backend website management interface, and you can directly access the website backend via a quick link, then manually change the user password.

Or click 'Modify Administrator Password' to change it directly from the server backend.

Change wordpress admin password 1646x798

Comparison of the four methods

Comparison DimensionsMethod 1
PHP Script
Method 2
Database
Method 3
functions.php
Method 4
Hosting Control Panel ⭐
Operation Difficulty⭐⭐ Medium⭐⭐⭐ More Difficult⭐⭐ Medium⭐ Easiest
Security⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
Time RequiredApproximately 5 minutesApproximately 10 minutesApproximately 5 minutesApproximately 2 minutes ⏱️
Technical RequirementsFile ManagementSQL BasicsCoding BasicsZero Foundation ✅
Applicable HostingVPS / Cloud ServerHas phpMyAdminAny HostingSiteGround/Hostinger, etc.
Automatic Cleanup✅ Automatic Deletion⚠️ Manual Operation⚠️ Requires Manual Deletion✅ Automatically Completed
Risk LevelLowest

🎯 Quick Selection Guide

Choose the most suitable method based on your hosting type:

  • Managed Hosting like SiteGround/Hostinger/Bluehost → Recommended Method Four: One-click Reset via Hosting Panel ✅ Easiest
  • VPS/Cloud Server (Baota Panel/Self-managed) → Recommended Method One: PHP Reset Script ✅ Safest
  • Only have database access → Method Two: Modify via phpMyAdmin
  • Only have FTP access, cannot log into the admin dashboard → Recommended Method One: PHP Reset Script ✅ Safest

As for Method Three? It's too complicated. If you have FTP, you can upload a PHP script to the server, using Method One is simpler.

Frequently Asked Questions (FAQ)

❓ Why can"t I receive the WordPress "Forgot Password" email?

Common reasons include:
- Server not configured with SMTP, causing email sending to fail
- Email is classified as spam
- Incorrect website domain email configuration
- Hosting provider restricts email sending functionality
It is recommended to directly reset the password using the four methods in this article, or first configure aWordPress SMTP PluginResolve email issues.

❓ What should I do if I still cannot log in after resetting my password?

Please check the following points:
1. Is the username correct? - Pay attention to case sensitivity
2. Is the password entered correctly? - It is recommended to copy and paste to avoid typos
3. Clear browser cache - Press Ctrl+F5 to force refresh the page
4. Check if multi-factor authentication is enabled - such as Google Authenticator, security plugins, etc.
5. Try logging in using private/incognito mode - to rule out browser plugin interference
If the issue persists, the website may be hacked or the database may be corrupted. It is recommended to contact your hosting provider or a professional.

❓ Will using these methods affect website data?

No. These four methods only modify the user password field and will not affect:
- Post content and pages
- Website settings and Theme configuration
- Plugin data and user profiles
- Other tables in the database
However, it is recommended to back up the website before proceeding, just in case.

❓ Which method is the most secure?

Method 1 (PHP reset script) and Method 4 (Host Control Panel) are the most secure.

❓ I'm a beginner and don't understand code at all. Which method should I use?

Method 4: Resetting via the Host Control Panel is highly recommended.
If you are using mainstream hosting providers like SiteGround, Hostinger, Bluehost, etc., you can complete the process with just a few clicks in the hosting Admin Dashboard without touching any code.

🚀 Still feeling confused after reading the tutorial? Let me guide you step-by-step instead.

「Naibabiji WordPress Website Building Coaching」 — From selecting a domain and purchasing hosting to installing themes and publishing posts, I「ll guide you through every step, helping you avoid detours and reach your goals directly.

👉 Learn about Website Building Coaching Service
🔒

Comments are closed

The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.

×
二维码

Scan to Follow