I installed mysql on Ubuntu 14.04 LTS like:

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

after completely removing mysql with:

sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser mysql
sudo rm -rf /var/lib/mysql

Everything works fine until I restart the mysql service with:

sudo service mysql restart

Then I can no longer login with the root user and password. I get the error access denied for root@localhost using password yes

My only guess: is it possible there are two instances of mysql installed?


All of the below are set as installfrom the output of:

dpkg --get-selections | grep -v deinstall | grep "mysql"

  • 2
    Did you follow the instructions to set a root password during the reinstall? if not, you can run sudo dpkg-reconfigure mysql-server-5.5 at any time to do so. – steeldriver May 27 '14 at 10:56
  • I was prompted to add a root password, which worked once it was installed before the restart. – Andrew Atkinson May 27 '14 at 13:11
  • Post the output for dpkg --get-selections | grep -v deinstall | grep "mysql". Only possible way to see whether any other instance matching mysql. Meanwhile try mysql -u username -p & then type the password when it prompts. – AzkerM May 27 '14 at 13:33
  • post updated @AzkerM – Andrew Atkinson May 27 '14 at 23:02

May be you need to reset mysql root password:

Change my.cnf configuration file:



Restart service, and login with root without password, then change the root password:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('your_new_password');

Remove skip-grant-tables entry from my.cnf and restart mysql.

| improve this answer | |
  • 1
    This results in ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement with mysql 5.5.38. – Bombe Oct 6 '14 at 16:33
  • If you try with: UPDATE mysql.user set password = PASSWORD('your_new_password') where user = 'root' and host = 'localhost' – Ivan Cachicatari Oct 6 '14 at 16:38
  • I had to be logged in as root and not ubuntu when starting mysql. – Jimbali Mar 16 '17 at 11:56
  • Also I had to use: update mysql.user set authentication_string=password('MyNewPass') where user='root'; – Jimbali Mar 16 '17 at 12:13
  • Change the ubuntu password using the same sql. – Ivan Cachicatari Mar 16 '17 at 12:15

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.