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

Posted: 23 października 2011 in Bazy danych, LAMP, Linux, MySql, SQL, WAMP, XAMPP
Tagi: , , , , , ,

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
Reklamy

Skomentuj

Wprowadź swoje dane lub kliknij jedną z tych ikon, aby się zalogować:

Logo WordPress.com

Komentujesz korzystając z konta WordPress.com. Wyloguj / Zmień )

Zdjęcie z Twittera

Komentujesz korzystając z konta Twitter. Wyloguj / Zmień )

Facebook photo

Komentujesz korzystając z konta Facebook. Wyloguj / Zmień )

Google+ photo

Komentujesz korzystając z konta Google+. Wyloguj / Zmień )

Connecting to %s