Home > Tips & Tricks, how-to > ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: NO)

ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: NO)

July 27th, 2009

Today I got the error below :

1
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

after typing :

1
mysql -u root

I don’t know why ? but I know how to solve it.
First of all let’s disable password authentication :
Stop your MySQL daemon:

1
/etc/init.d/mysql stop

or

1
/etc/init.d/mysqld stop


Then run the following command line in background :

1
mysqld_safe --skip-grant-tables &

Secondly run :

1
mysql -u root

Finally, In your MySQL command line prompt issue the following command:

1
2
3
4
USE mysql;
UPDATE user SET password=PASSWORD("my_password") WHERE user="root";
FLUSH PRIVILEGES;
EXIT

Password is now reset to my_password. So just restart your MySQL server using :

1
/etc/init.d/mysql restart

or

1
/etc/init.d/mysqld restart

and use your new password to authenticate :

1
mysql -u root -p

All that remains is to enter your password.

  • Share/Bookmark

Marouan OMEZZINE Tips & Tricks, how-to ,

  1. Gbenga
    August 27th, 2009 at 22:55 | #1

    still not working i have tried the steps over and over

  2. el arbi
    December 25th, 2009 at 07:12 | #2

    hello can you telle me pleaze how can we do it in windows (with wamp)

  3. Oussama
    June 4th, 2010 at 10:15 | #3

    Hello,
    I get this error on WAMP(Windows) when i tried to connect to the database via phpMyAdmin
    you can do the following :

    - go to %WAMP_DIR%\apps\phpmyadmin2.11.6\config.inc.php file
    - change the value of $cfg['Servers'][$i]['password'] to your password
    - restart the services (Apache & MySQL)

  1. No trackbacks yet.