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

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

>>disabling password authentication
[root@localhost]#service mysql stop

wait until MySQL shuts down. Then run

[root@localhost]#mysqld_safe --skip-grant-tables &

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

[root@localhost]#mysql -uroot mysql

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

mysql>UPDATE user SET password=PASSWORD("123456") WHERE user="root";
mysql>FLUSH PRIVILEGES;
mysql>EXIT

[root@localhost]#/etc/init.d/mysqld restart

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

#mysql -uroot -p mysql

0 comments:

Post a Comment