By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
  • Business
  • Politics
  • Travel
  • Entertainment
  • Science
  • Technology
  • Fashion
TechConvergence: Where DevOps, Cloud & Security Expertise Converge
  • Linux
    • Ubuntu
    • Debian
    • CentOS
    • Fedora
    • Arch
    • System Administration
    • Shell Scripting
    • Networking
    • Performance Tuning
  • Databases
    • Relational Databases
    • Database Design
    • Database Administration
    • Query Optimization
  • Windows
    • Windows Server
    • PowerShell
    • System Administration
    • Windows Networking
    • Performance Optimization
  • Cloud
    • AWS
    • Azure
    • Google Cloud
    • Multi-Cloud
    • Cloud Architecture
  • DevOps
    • CI/CD
    • Containerization
    • Infrastructure as Code
    • Monitoring & Observability
    • Orchestration
  • Security
    • Network Security
    • Identity & Access Management
    • Vulnerability Management
    • Security Hardening
    • Incident Response
  • General
    • Tutorials
    • Tools & Resources
    • Career Development
    • News & Trends
    • Case Studies
Reading: How to Change MySQL Server Password (Linux & Windows Guide 2025)
TechConvergence: Where DevOps, Cloud & Security Expertise ConvergeTechConvergence: Where DevOps, Cloud & Security Expertise Converge
Font ResizerAa
  • Business
  • Politics
  • Travel
  • Entertainment
  • Science
  • Technology
  • Fashion
Search
  • Home
  • Categories
    • Technology
    • Entertainment
    • Travel
    • Fashion
    • Business
    • Politics
    • Science
    • Health
  • Bookmarks
  • More Foxiz
    • Sitemap
Have an existing account? Sign In
Follow US
© Foxiz News Network. Ruby Design Company. All Rights Reserved.
mysql password change
TechConvergence: Where DevOps, Cloud & Security Expertise Converge > Databases > Database Administration > How to Change MySQL Server Password (Linux & Windows Guide 2025)
Database AdministrationRelational Databases

How to Change MySQL Server Password (Linux & Windows Guide 2025)

SunilJangra
Last updated: 2025/05/11 at 8:25 AM
SunilJangra 6 Min Read
Share
mysql password change

How to Change MySQL Server Password: A Step-by-Step 2025 Guide

Contents
Why Change Your MySQL Password?Method 1: Update MySQL Root Password (Linux – MySQL 5.7/8.0+)Step 1: Log in to MySQL ShellStep 2: Change the Root PasswordStep 3: Confirm the New Password Works🛠️ Method 2: Reset Root Password If Forgotten (Linux)Step 1: Stop the MySQL ServiceStep 2: Launch MySQL Without Access ControlStep 3: Log in Without a PasswordStep 4: Set a New Root PasswordStep 5: Restart MySQL NormallyStep 6: Test LoginMethod 3: Change MySQL Password on WindowsStep 1: Launch Command Prompt as AdminStep 2: Run mysqladmin to Change PasswordMethod 4: Update Password for a Different UserFixing Common Issues❗ “Access denied for user ‘root’@’localhost'”“ERROR 1820 (HY000): You must reset your password using ALTER USER”Enforce Strong Passwords with validate_passwordStep 1: Enable the PluginStep 2: Review Current Policy SettingsStep 3: Customize Strength RequirementsRun mysql_secure_installation Post-InstallMySQL Password Management Best PracticesSummaryWhat You Should Remember:Final Thoughts

MySQL remains a go-to database system for developers and administrators across the globe. Whether you’re tightening up security, updating login credentials, or recovering access after a lost password, knowing how to change your MySQL password is a must-have skill.

This guide breaks down the most effective ways to update MySQL server passwords — covering root and user accounts on both Linux and Windows systems. Plus, you’ll find troubleshooting tips and security enhancements to help keep your setup protected.

Why Change Your MySQL Password?

Here are a few common scenarios where updating the password becomes necessary:

  • Security issues: Compromised credentials, shared logins, or outdated passwords.
  • Policy updates: Enforced rotation cycles or new complexity requirements.
  • Forgotten access: You’ve lost the current root password.
  • Server changes: Post-migration adjustments require fresh credentials.
  • User updates: Resetting passwords for other MySQL accounts.

Method 1: Update MySQL Root Password (Linux – MySQL 5.7/8.0+)

Step 1: Log in to MySQL Shell

 

mysql password change
mysql password change
sudo mysql -u root -p

Enter your current root password when prompted.

Step 2: Change the Root Password

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NewSecurePassword@123';
FLUSH PRIVILEGES;
EXIT;

Tip: Swap out NewSecurePassword@123 with your new strong password.

Step 3: Confirm the New Password Works

mysql -u root -p

Log in using your new credentials to verify success.

🛠️ Method 2: Reset Root Password If Forgotten (Linux)

In case the root password is lost, here’s how to recover access:

Step 1: Stop the MySQL Service

sudo systemctl stop mysql

Step 2: Launch MySQL Without Access Control

sudo mysqld_safe --skip-grant-tables &

Step 3: Log in Without a Password

mysql -u root

Step 4: Set a New Root Password

FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword@123';
EXIT;

Step 5: Restart MySQL Normally

sudo systemctl restart mysql

Step 6: Test Login

mysql -u root -p

Method 3: Change MySQL Password on Windows

Step 1: Launch Command Prompt as Admin

Navigate to MySQL’s bin directory. Example:

cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"

Step 2: Run mysqladmin to Change Password

mysqladmin -u root -p password "NewSecurePassword@123"

You’ll be asked for the current password. Once entered, the change is applied.

Method 4: Update Password for a Different User

To update credentials for a user like adminuser, use:

ALTER USER 'adminuser'@'localhost' IDENTIFIED BY 'AdminNewPass#2025';

Just ensure you’re logged in as a user with enough privileges (typically root).

Fixing Common Issues

❗ “Access denied for user ‘root’@’localhost'”

  • Double-check you’re entering the right password.
  • If locked out, try the --skip-grant-tables method.
  • Some systems (like Ubuntu) may use the auth_socket plugin.

Run this to confirm:

SELECT user, host, plugin FROM mysql.user;

To switch back to password auth:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourPassword';

“ERROR 1820 (HY000): You must reset your password using ALTER USER”

MySQL might flag expired passwords. Fix with:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword@123';

Enforce Strong Passwords with validate_password

For stricter password rules, activate the validate_password plugin.

Step 1: Enable the Plugin

INSTALL PLUGIN validate_password SONAME 'validate_password.so';

Step 2: Review Current Policy Settings

SHOW VARIABLES LIKE 'validate_password%';

Step 3: Customize Strength Requirements

SET GLOBAL validate_password.length = 12;
SET GLOBAL validate_password.policy = STRONG;

This ensures future passwords meet complexity guidelines.

Run mysql_secure_installation Post-Install

This setup script helps harden MySQL:

sudo mysql_secure_installation

It walks you through:

  • Setting/changing root password
  • Removing anonymous accounts
  • Blocking remote root logins
  • Deleting test databases
  • Reloading privileges

MySQL Password Management Best Practices

  1. Use complex passwords
    Combine upper/lowercase letters, digits, and symbols.
  2. Rotate passwords regularly
    Especially for root or privileged accounts.
  3. Avoid overusing root
    Create limited-privilege accounts for daily tasks.
  4. Restrict login hosts
    Avoid '%'; prefer 'localhost' or known IPs.
  5. Enable logging
    Use general logs or auditing tools to track changes.

Summary

Changing your MySQL password is one of the simplest, yet most effective ways to safeguard your database. Whether you’re running Linux or Windows, MySQL makes it easy to update, recover, and manage user credentials securely.

What You Should Remember:

  • Use ALTER USER for MySQL 5.7 and newer.
  • mysqladmin offers a quick CLI method.
  • Recovery via --skip-grant-tables can save the day.
  • validate_password enforces password complexity.
  • Follow best practices to avoid future security gaps.

Final Thoughts

Strong database security starts at the login prompt. Managing your MySQL root and user passwords carefully — and regularly — helps keep your system protected. Whether you’re running a single server or managing enterprise clusters, password hygiene isn’t optional — it’s critical.

Share This Article
Facebook Twitter Email Copy Link Print
What do you think?
Love0
Happy0
Joy0
Next Article Secure Your Ubuntu Server in 2025: Complete Step-by-Step Guide
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Latest Tech

How to Install Docker on CentOS
How to Install Docker on CentOS/RHEL 8/7 and Use Containers – Step-by-Step Guide (2025)
2 days ago
How to Install Git on Red Hat Enterprise Linux 9
How to Install Git on Red Hat Enterprise Linux 9 (RHEL 9) – Step-by-Step Guide
2 days ago
Secure Your Ubuntu Server in 2025: Complete Step-by-Step Guide
3 days ago

Sport News

Socials

Facebook Twitter Youtube

Company

Made by ThemeRuby using the Foxiz theme. Powered by WordPress

Join Us!

Subscribe to our newsletter and never miss our latest news, podcasts etc..

[mc4wp_form]
Zero spam, Unsubscribe at any time.
Welcome Back!

Sign in to your account

Lost your password?