Sunday, June 14, 2009

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

[root@sylesh ~]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

>>disabling password authentication
service mysql stop

wait until MySQL shuts down. Then run

mysqld_safe --skip-grant-tables &

then you will be able to login as root with no password.

mysql -uroot mysql

In MySQL command line prompt issue the following command:
use databasename;

UPDATE user SET password=PASSWORD("abcd") WHERE user="root";
FLUSH PRIVILEGES;
EXIT

/etc/init.d/mysqld restart

At this time your root password is reset to "abcd" and MySQL will now
know the privileges and you'll be able to login with your new password:

mysql -uroot -p mysql

9 comments:

gillus said...

Thanks a lot ,
there are so much flooding and fucking posts on the net
but this clear article resolved my problem quickly on my exotic linux os

Anonymous said...

Just be thankful, bu keep from using foul language! or you won't get support!

Anonymous said...

very useful article that resolve my problem !!
Karim

ck said...

Hey, you might want to remind people to start their mysql again before trying "mysql -u root mysql"

Anonymous said...

Worked for me. Perhaps it's the double quotes?

Unknown said...

hi . good one it worked for me thanks

Manas said...

Thanks buddy. This post is very precise & correct.

Anonymous said...

excelent......
bye simone
www.hobbylinux.com :P

Anonymous said...

thank you.. worked