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

Posted: July 22, 2013 in Databases

Sometimes while installing mysql or upgrading mysql can get the following error:

[root@xxxx ~]# mysql
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)

To resolve this issue, please follow the snippet pasted below:

[root@xxxx ~]# service mysql stop
Shutting down MySQL.. SUCCESS!

[root@xxxx ~]# cd /usr/bin/

[root@xxxx bin]# mysqld_safe --skip-grant-tables &

130722 21:00:30 mysqld_safe Logging to ‘/var/lib/mysql/V-6862.volumedrive.com.err’.
130722 21:00:30 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

  • Open another terminal and open a mysql session to execute this:

[root@xxxx~]# mysql

mysql> use mysql;

mysql> UPDATE user SET password=PASSWORD('NEW_PASSWORD_HERE') WHERE user = 'root';

exit;

  • Now kill the mysqld_safe process and restart mysqld normally:

[root@xxxx~]# service mysql start

Starting MySQL SUCCESS!

Issue Fixed! 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s