MySQL 5.7.20 unable to set root password

Try

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mypasswordhere';

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

If you install 5.7 and don’t provide a password to the root user, it will use the auth_socket plugin. That plugin doesn’t care and doesn’t need a password. It just checks if the user is connecting using a UNIX socket and then compares the username. If we want to configure a password, we need to change the plugin and set the password at the same time, in the same command.


After installing Mysql on Ubuntu and similar one should run mysql_secure_installation command .

It clears some possible problems and one of the things is it asks for a new root password.

But previous answer from @Valuator will change the password.

Tags:

Mysql