Mysql – thesql_secure_installation doesnt set root password

MySQLubuntu-18.04

I am running Ubuntu 18.04 (Server version: 5.7.28-0ubuntu0.18.04.4 (Ubuntu)) and have done a fresh mysql installation. I've used mysql_secure_installation and set a root password. However when I then go (logged in as root) mysql -u root -p and enter a blank password I am still able to login to the MySQL server. I've done flush privileges, I've tried Unable to set mysql root password and I notice a similar (but unanswered) issue here: mysql_secure_installation on Ubuntu 16.04 doesn't set the root pass.

Why would MySQL not store/save the root password? Interestingly if I try to connect as a non-root user I am not able to connect with empty OR the password.

Best Answer

So it turns out that MySQL 5.7 now allows a user of the same name to access MySQL if the authentication type is "auth_socket". I'm personally not a fan - so the solution was found here:

https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/