0

Refer from this question (Resetting forgotten phpmyadmin password) I am trying to reset the password of mysql installed.But run the third command mysql -u root mysql i will get the error

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: N
O).

I have searched a lot but cant find a solution.Currently the virtual machine is running in azure cloud service

1 Answers1

1

To reset your mysqld password just follow these instructions :

Stop the mysql demon process using this command :

sudo service mysql stop

Start the mysqld demon process using the --skip-grant-tables option with this command

sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &

Because you are not checking user privs at this point, it's safest to disable networking. In Dapper, /usr/bin/mysqld... did not work. However, mysqld --skip-grant-tables did.

start the mysql client process using this command

mysql -u root

from the mysql prompt execute this command to be able to change any password

FLUSH PRIVILEGES;

Then reset/update your password

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

If you have a mysql root account that can connect from everywhere, you should also do:

UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';

Check this official help


If the above method didn't work check this.

Check the version of your mysql-server;

apt-cache policy mysql-server

Now you can know mysql-server-X.X installed in your system.

  1. Start the reconfiguration with:

    sudo dpkg-reconfigure mysql-server-X.X
    

This will prompt you to enter your new password and confirm the reconfiguration.

snap1

  1. Now you can log in :

    mysql -u root -p
    
Maythux
  • 84,289
  • I tried the second method and reset the password.but it again get the same error – shamon shamsudeen Apr 24 '15 at 06:15
  • Then purge the server and install again as stated in offcial link https://help.ubuntu.com/community/MysqlPasswordReset But you 'll loose all your mysql data – Maythux Apr 24 '15 at 06:16