Endless loop in mysql_secure_installation

Viewed 3078

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?

1 Answers

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 it with your new password (-p prompts for it).

sudo mysql_secure_installation -p
Related