Cannot change MySQL root password I have run the following commands found here.

shell&gt; mysql
mysql&gt; FLUSH PRIVILEGES;
mysql&gt; ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass'


But when I go to login as root, I can type any string as a password, and it will still let me login.

How can I enforce a password for root, and not allow anonymous users by simply typing mysql
The following worked for me:

I ran through the command line wizard to set this up:
shell&gt; mysql_secure_installation  

Then entered the following:
shell&gt; mysql
ALTER USER 'root'@'localhost' IDENTIFIED with mysql_native_password;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';  

Credit goes to this question/answer.