I recently followed some tutorials and installed mysql using
sudo apt-get install mysql-server-5.7
I can connect to the database using password by running the following command:
sudo mysql -u root -p
I try to connect by running:
mysql -u root -p
but I get the error:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Why? How can I fix this?
Best Answer
sudo mysql -u root -p
drop user 'root'@'localhost';
create user 'root'@'%' identified by 'your_password';
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;
Font: can't login as mysql user root from normal user account in ubuntu 16.04