---
title: "Change a MySQL User Password"
source: "https://docs.nexcess.com/hosting/server-administration/database-management/mariadb-mysql/change-a-mysql-user-password/"
description: "Changing MySQL passwords to something new and secure is easy via the command line."
vertical: "Hosting"
date: "2024-03-04"
last_modified: "2026-07-27"
---

# Change a MySQL User Password

If you have created MySQL users to help you organize your database management, you might need to change user passwords for security reasons. If you’re comfortable with the command line, it only takes a few minutes to change MySQL user passwords.

## Using Command Line to Change MySQL Passwords

1. Using the terminal program of your choice, log into your server as root. If you haven’t logged into your server using the command line before, read [Logging into Your Server via Secure Shell (SSH)](https://docs.nexcess.com/hosting/server-administration/linux/logging-into-your-server-via-secure-shell-ssh/) first.
2. Now you’ll log into your MySQL server by typing  
    ```
    mysql -u root -p
    ```
    
      
    Then press **Enter**. The *-u root* flag tells MySQL you want to log in as the root **u**ser, and the *-p* flag prompts MySQL to ask you for a **p**assword. When prompted, enter your root password and press **Enter**.
3. You’ll now see a MySQL prompt that looks like  
    ```
    mysql>
    ```
4. All the user data is stored in its own table in MySQL. So, navigate to the table by typing  
    ```
    USE mysql;
    ```
5. Then press **Enter**.
6. Now you’ll update the row where the user information is stored using this syntax:  
    ```
    UPDATE user SET Password=PASSWORD('password1') WHERE user='username';
    ```
    
      
      
    
    - Replace “password1” with the new password.
      
    - Replace “username” with the username that needs a new password.
      
    
      
    Then press **Enter**.
7. You’ve successfully changed your user’s password!
