$ 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


sudo dpkg-reconfigure mysql-server-5.5


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


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> exit
$ service mysql restart
$ mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
  • Please give a source for your solution and accept it as solution. – Björn May 14 '17 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.