'Endless loop in mysql_secure_installation

After installing mysql-server, I did

sudo mysql_secure_installation

in order to secure the server deployment. I indicate that I would like to setup VALIDATE PASSWORD plugin when I'm asked. Then I am running into this endless loop, even my password strength is 100.

New password: 

Re-enter new password: 

Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
 ... Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.

New password:

I tried uninstall mysql-* and purge mysql-*, then run this mysql_secure_installation again, and I still run into this.

My server is Ubuntu 22.04.

What could I do now?



Solution 1:[1]

You need to change the authentication parameters. To do so run this command in MySQL:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'mynewpassword';

Afterwards you should be able to run

sudo mysql_secure_installation

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sanju Sanjani