WordPress / 12 MIN READ
MAMP WP Password DB
How to manage WordPress user passwords in MAMP
From the original Fervor library. Examples may use older package versions.
How to Change a WordPress User Password Directly in the Database Using MAMP
If you’ve forgotten your WordPress admin password or need to reset it directly in the database, you can do so using MAMP’s phpMyAdmin tool. This tutorial will guide you through the process of changing a user’s password in your WordPress database while working in a local MAMP environment.
Table of Contents
- Prerequisites
- Step 1: Access phpMyAdmin via MAMP
- Step 2: Select Your WordPress Database
- Step 3: Locate the
wp_usersTable - Step 4: Find the User to Update
- Step 5: Edit the User’s Password
- Step 6: Save the Changes
- Step 7: Test the New Password
- Conclusion
1. Prerequisites
Before proceeding, ensure you have the following:
- MAMP Installed: Ensure MAMP is installed and running on your computer.
- phpMyAdmin Access: MAMP includes phpMyAdmin for managing your databases.
- WordPress Installed Locally: You should have a WordPress site set up in your local MAMP environment.
- Database Credentials: Familiarity with your WordPress database name and user details.
Important: Always back up your database before making direct changes to prevent data loss.
2. Step 1: Access phpMyAdmin via MAMP
-
Start MAMP:
- Open the MAMP application on your computer.
- Click the Start Servers button if they aren’t already running. Ensure both Apache and MySQL servers are running.
-
Open phpMyAdmin:
- Once the servers are running, click the Open WebStart page button in MAMP.
- In the WebStart page, locate and click on the phpMyAdmin link. Alternatively, you can directly navigate to http://localhost:8888/phpmyadmin/ in your web browser.

MAMP WebStart Page with phpMyAdmin link highlighted.
3. Step 2: Select Your WordPress Database
-
Identify Your Database:
- In the left sidebar of phpMyAdmin, you’ll see a list of databases.
- Locate the database associated with your WordPress installation. If you’re unsure of the database name:
- Open the
wp-config.phpfile in your WordPress root directory. - Look for the line:
define('DB_NAME', 'your_database_name'); - Replace
'your_database_name'with the actual name found in yourwp-config.php.
- Open the
-
Select the Database:
- Click on your WordPress database name to view its tables.

phpMyAdmin interface showing the list of tables in the selected database.
4. Step 3: Locate the wp_users Table
-
Find the
wp_usersTable:- Within your WordPress database, locate the table named
wp_users.
Note: If you have a custom table prefix, it might be something likewpabc_users.
- Within your WordPress database, locate the table named
-
Open the Table:
- Click on the
wp_userstable to view its contents.

phpMyAdmin showing thewp_userstable. - Click on the
5. Step 4: Find the User to Update
-
Browse Users:
- In the
wp_userstable, you’ll see a list of all WordPress users. - Identify the user whose password you want to change. This is typically your admin user.
- In the
-
Edit User Details:
- Next to the user, click the Edit link (often represented by a pencil icon).

phpMyAdmin with the Edit option for a user.
6. Step 5: Edit the User’s Password
-
Locate the
user_passField:- In the user’s profile, find the
user_passfield. This field stores the user’s password in an encrypted format.
- In the user’s profile, find the
-
Change the Password:
-
Method 1: Using MD5 Hash (Simplest Method)
- In the Function dropdown next to
user_pass, select MD5. - In the Value field, enter your new desired password in plain text.

phpMyAdmin showing the password change using MD5.Example:
- Function:
MD5 - Value:
NewSecurePassword123
- In the Function dropdown next to
-
Method 2: Using WordPress’s Password Hashing (Advanced)
- WordPress uses a more secure hashing mechanism (bcrypt) rather than MD5. However, phpMyAdmin doesn’t support WordPress’s hashing out of the box.
- To use WordPress’s hashing:
- Generate a Hashed Password:
- Use a PHP script or an online tool that can generate a WordPress-compatible password hash.
- Example PHP script:
Note: This requires access to WordPress’s functions. Alternatively, use a reputable online tool.<?php echo wp_hash_password('NewSecurePassword123'); ?>
- Insert the Hashed Password:
- In the
user_passfield, select Custom from the Function dropdown. - Paste the hashed password into the Value field.
- In the
- Generate a Hashed Password:
Warning: This method is more complex and generally not necessary unless you have specific security requirements.
Recommendation: Use Method 1 (MD5) for simplicity. WordPress will automatically rehash the password to its secure format upon the next login.
-
7. Step 6: Save the Changes
-
Apply the Changes:
- After entering the new password, scroll down to the bottom of the page.
- Click the Go button to save the changes.

phpMyAdmin interface showing the Save Changes button. -
Confirmation:
- You should see a message confirming that the query was successfully executed.

phpMyAdmin success message after updating the password.
8. Step 7: Test the New Password
-
Access Your WordPress Site:
- Open your web browser and navigate to your local WordPress login page, typically http://localhost:8888/your-site/wp-admin/.
-
Login with the New Password:
- Enter the username of the account you updated.
- Use the new password you set in the database.
-
Verify Successful Login:
- If the password was updated correctly, you should gain access to the WordPress dashboard.

WordPress dashboard after successful login.Note: Upon successful login, WordPress will automatically rehash your password using its secure hashing mechanism, replacing the MD5 hash.
9. Conclusion
Changing a WordPress user’s password directly in the database using MAMP’s phpMyAdmin is a straightforward process that can be invaluable, especially in local development environments. By following the steps outlined above, you can securely reset user passwords without relying on email-based recovery methods.
Best Practices:
- Backup Before Changes: Always back up your database before making direct changes to prevent accidental data loss.
- Use Strong Passwords: Ensure that new passwords are strong and unique to maintain site security.
- Limit Direct Database Access: While working locally is safe, exercise caution when performing similar actions on live sites.
Bonus Stuff
Enhancing Your WordPress Password Reset Tutorial: Bonus Tips and Advanced Techniques
Great to hear that you found the tutorial on changing a WordPress user password via MAMP helpful! To further empower you in managing your local WordPress environment, here are some cool and bonus additions you can incorporate into your workflow. These enhancements not only streamline your user management but also bolster your site’s security and efficiency.
Table of Contents
- Creating a New Admin User via phpMyAdmin
- Bulk Updating Multiple User Passwords
- Using SQL Queries for Password Management
- Integrating WordPress Functions for Secure Password Hashing
- Best Security Practices When Managing Passwords
- Automating Password Changes with PHP Scripts
- Troubleshooting Common Issues After Password Changes
- Conclusion
1. Creating a New Admin User via phpMyAdmin
Sometimes, especially during development or troubleshooting, you might need to create a new admin user directly through the database. Here’s how you can do it:
Step-by-Step Guide
-
Access phpMyAdmin:
- Open http://localhost:8888/phpmyadmin/ in your browser.
-
Select Your WordPress Database:
- Click on your WordPress database from the left sidebar.
-
Navigate to the
wp_usersTable:- Click on the
wp_userstable.
- Click on the
-
Insert a New User:
- Click on the Insert tab to add a new user.
-
Fill in the User Details:
- ID: Leave this blank; it will auto-increment.
- user_login:
newadmin - user_pass: Use the MD5 function and enter your desired password (e.g.,
NewAdminPassword123) - user_nicename:
newadmin - user_email:
newadmin@example.com - user_url:
http://localhost:8888/your-site - user_registered:
YYYY-MM-DD HH:MM:SS(current timestamp) - user_activation_key: Leave blank.
- user_status:
0 - display_name:
New Admin
-
Execute the Insert:
- Scroll down and click Go to save the new user.
-
Assign Admin Role:
- Navigate to the
wp_usermetatable. - Insert two new entries:
- First Entry:
- umeta_id: Leave blank.
- user_id: ID of the newly created user.
- meta_key:
wp_capabilities - meta_value:
a:1:{s:13:"administrator";b:1;}
- Second Entry:
- umeta_id: Leave blank.
- user_id: ID of the newly created user.
- meta_key:
wp_user_level - meta_value:
10
- First Entry:
- Navigate to the
-
Save Changes:
- Click Go after each insert.
-
Login with New Admin Credentials:
- Visit your WordPress login page and log in with the new admin credentials.
Security Note
After creating a new admin user, ensure you delete any unnecessary admin accounts and use strong, unique passwords to maintain site security.
2. Bulk Updating Multiple User Passwords
If you need to update passwords for multiple users simultaneously—perhaps after a security breach—you can perform bulk updates using SQL queries.
Using SQL to Update Multiple Passwords
-
Access phpMyAdmin and Select Database:
- Navigate to your WordPress database.
-
Open the SQL Tab:
- Click on the SQL tab to run custom queries.
-
Execute a Bulk Update Query:
- To set all user passwords to a default password (e.g.,
DefaultPass123), use the following query:
Explanation:UPDATE `wp_users` SET `user_pass` = MD5('DefaultPass123') WHERE `user_login` != 'admin';- This sets the password for all users except the user with
user_loginas ‘admin’.
- This sets the password for all users except the user with
- To set all user passwords to a default password (e.g.,
-
Run the Query:
- Click Go to execute.
Caution
- Backup First: Always back up your database before performing bulk operations.
- Selective Updates: Modify the
WHEREclause to target specific users as needed.
3. Using SQL Queries for Password Management
Understanding and utilizing SQL queries can provide more control and flexibility in managing user passwords.
Example: Resetting a Password for a Specific User
UPDATE `wp_users` SET `user_pass` = MD5('YourNewPassword') WHERE `user_login` = 'username';
Steps:
- Navigate to the SQL Tab in phpMyAdmin.
- Enter the Query:
- Replace
'YourNewPassword'with the desired password. - Replace
'username'with the actual username.
- Replace
- Execute the Query:
- Click Go to run.
Benefits
- Precision: Update specific users without manual edits.
- Efficiency: Save time when managing multiple users.
4. Integrating WordPress Functions for Secure Password Hashing
While using MD5 is straightforward, WordPress employs more secure hashing mechanisms (bcrypt) for passwords. To align with WordPress’s security standards, you can utilize PHP scripts to generate hashed passwords.
Creating a PHP Script to Generate a WordPress-Compatible Password Hash
-
Create a PHP File:
- In your WordPress root directory, create a file named
generate-password.php.
- In your WordPress root directory, create a file named
-
Add the Following Code:
<?php require_once('wp-load.php'); // Ensure WordPress functions are accessible if (isset($_GET['password'])) { $password = $_GET['password']; $hashed_password = wp_hash_password($password); echo 'Hashed Password: ' . $hashed_password; } else { echo 'Please provide a password using the "password" GET parameter.'; } ?> -
Run the Script:
-
Copy the Hashed Password:
- The script will display the hashed version of your password.
-
Update the Database:
- In phpMyAdmin, navigate to the
wp_userstable. - Edit the
user_passfield for the desired user. - Select Custom in the Function dropdown.
- Paste the hashed password into the Value field.
- Click Go to save.
- In phpMyAdmin, navigate to the
-
Delete the Script:
- For security reasons, delete the
generate-password.phpfile after use.
- For security reasons, delete the
Advantages
- Security: Uses WordPress’s native hashing mechanisms, ensuring password security.
- Compliance: Aligns with WordPress’s password management standards.
5. Best Security Practices When Managing Passwords
Ensuring the security of user passwords is paramount. Here are some best practices to follow:
a. Always Backup Before Making Changes
- Why: Prevents data loss in case of errors.
- How: Use phpMyAdmin’s export feature to create backups before modifications.
b. Use Strong, Unique Passwords
- Characteristics:
- At least 12 characters.
- Combination of uppercase, lowercase, numbers, and symbols.
- Tools: Utilize password managers like LastPass or 1Password to generate and store secure passwords.
c. Limit Direct Database Access
- Why: Reduces the risk of unauthorized modifications.
- How:
- Use strong credentials for phpMyAdmin.
- Restrict access to phpMyAdmin by IP or use secure connections.
d. Regularly Update WordPress and Plugins
- Why: Ensures you have the latest security patches.
- How: Keep your WordPress installation, themes, and plugins up to date through the dashboard or manually.
e. Implement Two-Factor Authentication (2FA)
- Benefits: Adds an extra layer of security beyond passwords.
- How: Use plugins like Google Authenticator or Two Factor Authentication to enable 2FA.
f. Monitor User Activity
- Why: Helps detect suspicious activities.
- Tools: Use plugins like Wordfence or Sucuri Security to monitor and protect your site.
6. Automating Password Changes with PHP Scripts
For developers who frequently manage passwords or require automation, creating PHP scripts can streamline the process.
Example: Automate Password Reset for All Users
-
Create a PHP File:
- Name it
bulk-password-reset.phpin your WordPress root directory.
- Name it
-
Add the Following Code:
<?php require_once('wp-load.php'); // Access WordPress functions // Define the new password $new_password = 'BulkResetPassword123!'; // Get all users $users = get_users(); foreach ($users as $user) { // Update each user's password wp_set_password($new_password, $user->ID); echo 'Password updated for user: ' . $user->user_login . '<br>'; } echo 'All user passwords have been reset.'; ?> -
Run the Script:
-
Confirmation:
- The script will display a confirmation message for each user.
-
Delete the Script:
- Remove the
bulk-password-reset.phpfile after execution to maintain security.
- Remove the
Advantages
- Efficiency: Quickly reset passwords for multiple users.
- Automation: Integrate into larger scripts or workflows as needed.
Caution
- Security Risk: Ensure such scripts are deleted after use to prevent unauthorized access.
- Inform Users: If applicable, inform users about password resets to maintain transparency.
7. Troubleshooting Common Issues After Password Changes
After changing passwords directly in the database, you might encounter some issues. Here’s how to address them:
a. Unable to Log In
- Solution:
- Double-Check Password Entry: Ensure you’ve entered the new password correctly.
- Clear Browser Cache: Sometimes, cached data can interfere with login.
- Verify User Capabilities: Ensure the user has the necessary permissions (e.g., administrator).
b. Password Not Updating Properly
- Solution:
- Ensure Proper Hashing: If using MD5, WordPress should rehash upon login. If not, consider using the PHP script method for bcrypt hashing.
- Check Database Updates: Verify in phpMyAdmin that the
user_passfield has been updated correctly.
c. Site Redirects or Errors After Password Reset
- Solution:
- Review
.htaccessFile: Ensure there are no misconfigurations causing redirects. - Check Theme and Plugin Compatibility: Sometimes, plugins or themes can interfere. Temporarily disable them to identify conflicts.
- Review
d. Missing Users After Import or Migration
- Solution:
- Verify
wp_usersTable: Ensure all user entries exist. - Check Usermeta Entries: Users rely on metadata in the
wp_usermetatable. Ensure related entries are present.
- Verify
e. Security Alerts or Suspicious Activity
- Solution:
- Audit User Accounts: Remove any unfamiliar or unauthorized users.
- Change Passwords: Reset passwords for all admin accounts.
- Update Security Plugins: Ensure security plugins are active and up to date.
8. Conclusion
Managing WordPress user passwords directly through the database using MAMP’s phpMyAdmin is a powerful technique, especially for local development and troubleshooting. By incorporating these bonus tips and advanced techniques, you can enhance your user management capabilities, ensure robust security, and streamline your workflow.
Key Takeaways:
- Flexibility: Direct database access allows for precise control over user accounts.
- Security: Implement best practices to safeguard user data and site integrity.
- Efficiency: Utilize scripts and SQL queries to automate and manage tasks effectively.
- Troubleshooting: Be prepared to address common issues that may arise post-password changes.
Always remember to backup your database before making any changes and limit direct database access to maintain security. With these additional tools and knowledge, you’ll be well-equipped to handle user management tasks confidently within your MAMP-powered WordPress environment.