Software >> Services >> RDBMS >> MySQL >> How to enable mysql root user login without being OS superuser (sudo)

By default the mysql root user can only be logged in by superuser

e.g. if you are not currently root, the following will fail

$ mysql -uroot -p<your password>

 

But the following will work,

$ sudo mysql -uroot -p<yourpassword>


This can potentially affect your ability to login to the mysql root user from clients such as mysql-workbench.

 

To fix this login with root prilege to mysql and set root to use mysql native password

mysql > ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourRootPassword';

mysql > FLUSH PRIVILEGES;