MySQL · December 20, 2023

How to Fix MySQL Error 1275 - SQLSTATE: HY000 (ER_SERVER_IS_IN_SECURE_AUTH_MODE) Server is running in --secure-auth mode, but '%s'@'%s' has a password in the old format; please change the password to the new format

How to Fix MySQL Error 1275 - SQLSTATE: HY000 (ER_SERVER_IS_IN_SECURE_AUTH_MODE)

MySQL is a popular open-source relational database management system used by many websites and applications. However, sometimes users may encounter an error message that says "Error 1275 - SQLSTATE: HY000 (ER_SERVER_IS_IN_SECURE_AUTH_MODE) Server is running in --secure-auth mode, but '%s'@'%s' has a password in the old format; please change the password to the new format." This error occurs when the MySQL server is running in secure authentication mode, but the user account has a password in the old format.

Understanding the Error

Before we dive into the solution, let's understand the error message in more detail. The error message consists of two parts:

  1. Error Code: 1275 - SQLSTATE: HY000 (ER_SERVER_IS_IN_SECURE_AUTH_MODE)
  2. Error Message: Server is running in --secure-auth mode, but '%s'@'%s' has a password in the old format; please change the password to the new format.

The error code "1275" indicates that the server is running in secure authentication mode. Secure authentication mode is a feature introduced in MySQL 5.7.5 to enhance the security of user authentication. It requires user accounts to have passwords stored in the new format, which uses a stronger hashing algorithm.

The error message indicates that the user account specified in '%s'@'%s' has a password in the old format. This means that the password for the user account needs to be updated to the new format to comply with the secure authentication mode.

Fixing the Error

To fix the MySQL error 1275, you need to update the password for the user account to the new format. Here are the steps to follow:

  1. Step 1: Connect to the MySQL server using a client application or the command line.
  2. Step 2: Identify the user account that needs to be updated. In the error message, '%s'@'%s' represents the username and the host from which the user is connecting.
  3. Step 3: Change the password for the user account using the following command:
ALTER USER 'username'@'host' IDENTIFIED WITH mysql_native_password BY 'new_password';

Replace 'username' with the actual username and 'host' with the actual host from the error message. Also, replace 'new_password' with the desired new password for the user account.

For example, if the error message is "Server is running in --secure-auth mode, but 'john'@'localhost' has a password in the old format; please change the password to the new format," you would use the following command:

ALTER USER 'john'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';

Make sure to choose a strong password that meets the MySQL password requirements.

Once you have executed the command, the password for the user account will be updated to the new format, and the error should no longer occur.

Summary

In conclusion, the MySQL error 1275 - SQLSTATE: HY000 (ER_SERVER_IS_IN_SECURE_AUTH_MODE) occurs when the server is running in secure authentication mode, but the user account has a password in the old format. To fix the error, you need to update the password for the user account to the new format using the ALTER USER command. For more information about VPS hosting and how it can benefit your website or application, visit Server.HK.