I have followed this tutorial to install MySQL but after successfully installed MySQL, I could not access database.
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
I found a solution at here link, by following this solution I have solved my problem.
Short steps are:
sudo mysql -u root ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';
test is a new password for the root user. Also, remember to run the command
sudo service mysql restart after altering the user.
I found another way that is much better as we need not to give any password for local system.
It is as followed.
Open terminal and type
sudo mysql -u root -p
It will prompt you in mysql, here you can fire any mysql commands.
Use mysql table for change table type, so we can use empty password. Bellow is command for it
Now we change type of table by following command
UPDATE user SET plugin='mysql_native_password' WHERE User='root';
now we have to flush the privileges, because we have used UPDATE. If you use INSERT, UPDATE or DELETE on grant tables directly you need use FLUSH PRIVILEGES in order to reload the grant tables.
now exit from mysql by following command
now restart mysql server by following command
service mysql restart
Hope this may help