niedziela, 23 października 2011

Access denied for user 'root'@'localhost' (using password: NO)

Sometime I have this problem: Access denied for user 'root'@'localhost' (using password: NO) I have described solution below:

  • Start the mysql client process using this command (sudo /etc/init.d/mysql start):
    mysql -u root


  • 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 we have a mysql root account that can connect from everywhere, you should also do:
    UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';

    Alternate Method:
    USE mysql UPDATE user SET Password = PASSWORD('newpassword') WHERE Host = 'localhost' AND User = 'root';

    And if you have a root account that can access from everywhere:
    USE mysql UPDATE user SET Password = PASSWORD('newpassword') WHERE Host = '%' AND User = 'root';


  • Or faster:


USE mysql;
FLUSH PRIVILEGES;
UPDATE user SET Password = PASSWORD('dupa') WHERE Host = '%' AND User = 'root';


 

Then stop/restart the mysqld process:
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

or

sudo /etc/init.d/mysql restart

Brak komentarzy:

Prześlij komentarz