0

Error:

$ mysql -u root -p
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

I did sudo-apt-get install mysql-server.
I entered a blank for the root password when prompted.

However I'm unable to get into mysql using mysql - u root

I tried uninstalling again and reinstalling and also using

sudo service mysql stop

and

sudo dpkg-reconfigure mysql-server-5.5

and

sudo dpkg-reconfigure mysql-server-5.5 --force

but it did not ask me to set the root password (screen never came up) and I am still being asked for it in mysql

1 Answer 1

1

The answer was to set the authentication method for root as follows:

$ sudo mysql -u root
...
mysql> USE mysql
...
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> FLUSH PRIVILEGES 
mysql> exit
$ service mysql restart
$ mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
...
mysql> 
1
  • Please give a source for your solution and accept it as solution.
    – Björn
    May 14, 2017 at 11:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .