Mysql – cannot login to thesql root from vagrant, but can from sudo

MySQLvagrant

I just reinstall mysql, which is now running 5.7.9. I'm using vagrant.

I try to login to mysql with mysql -u root -proot and I get: ERROR 1698 (28000): Access denied for user 'root'@'localhost'

I then ran sudo -i, and mysql -u root -proot, and it allowed me to login with full root access.

Any idea why this is and how do I fix it? is the root user secured in some way on newer versions of mysql that make it inaccessible unless you're a sudo/root user in ubuntu?

Best Answer

Try these things: Try login by using vagrant as username instead of root, if that satisfies your problem.

Other things you can try is: Changing the password for root. Check the users using:

sudo mysql 
SELECT * FROM mysql.user

Check if you have user named root then try:

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

You may get some warnings, use SHOW WARNINGS to see them. Below link may help: https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/

Related Topic