Change MySQL user password


When to change MySQL password?

It's recommended to change the password when:

  • ✅ You received a default password
  • ✅ You want to improve security
  • ✅ Someone else had access and should no longer have it
  • ✅ For periodic security best practices

Method 1: From phpMyAdmin

Step 1: Access phpMyAdmin

  • Log in to phpMyAdmin
  • Log in with your credentials

Step 2: Go to User accounts tab

  • Click on the User accounts tab

Step 3: Select the user

  • Find the user whose password you want to change
  • Click Edit privileges

Step 4: Change password

  • Look for the Change password section
  • Enter the new password twice
  • Click Go or Continue

Method 2: From terminal (MySQL)

Step 1: Connect to MySQL

mysql -u root -p

Enter the current root password.

Step 2: Change current user password

If you want to change your own password:

ALTER USER 'username'@'localhost' IDENTIFIED BY 'new_password';

Example:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPassword123!';

Step 3: Apply changes

FLUSH PRIVILEGES;

Method 3: Change another user's password

If you are root or have permissions, you can change any user's password:

ALTER USER 'username'@'localhost' IDENTIFIED BY 'new_password';
FLUSH PRIVILEGES;

Example:

ALTER USER 'app_user'@'localhost' IDENTIFIED BY 'NewPassword456!';
FLUSH PRIVILEGES;

Method 4: Using SET PASSWORD (alternative method)

You can also use the SET PASSWORD command:

SET PASSWORD FOR 'username'@'localhost' = PASSWORD('new_password');
FLUSH PRIVILEGES;

Note: In modern MySQL versions (5.7.6+), ALTER USER is recommended instead of SET PASSWORD.


Change password without knowing current one (root only)

If you forgot the root password and have server access:

Step 1: Stop MySQL

sudo systemctl stop mysql
# Or on some systems:
sudo service mysql stop

Step 2: Start MySQL in safe mode

sudo mysqld_safe --skip-grant-tables &

Step 3: Connect without password

mysql -u root

Step 4: Change password

USE mysql;
UPDATE user SET authentication_string=PASSWORD('new_password') WHERE User='root';
FLUSH PRIVILEGES;
exit;

Step 5: Restart MySQL normally

sudo systemctl restart mysql

⚠️ Warning: This method should only be used if you have physical or SSH access to the server and it's an emergency situation.


Verify the change worked

Try connecting with the new password:

mysql -u username -p

Enter the new password. If it works, the change was successful.


Common issues

"Access denied" error after change

  • Verify that you typed the password correctly
  • Verify that you ran FLUSH PRIVILEGES
  • Wait a few seconds and try again

Can't access phpMyAdmin after change

  • Update the password in phpMyAdmin configuration file if necessary
  • Or use the new password to log in

Application doesn't connect after change

  • Update the password in your application's configuration file
  • Verify that username and password are correct

Security tips

  • ✅ Use strong passwords (minimum 12 characters, with letters, numbers, and symbols)
  • ✅ Don't use common or predictable passwords
  • ✅ Change passwords periodically
  • ✅ Don't share passwords via email or unencrypted messages
  • ✅ Use different passwords for different users
  • ✅ Consider using SSH key authentication instead of passwords

Need help?

If you're having trouble changing the password or lost access, open a ticket from the billing.baires.host panel or contact us for support.

You can also reach us through our social media:

Was this answer helpful? 0 Users Found This Useful (0 Votes)