You may receive the “Access denied for user ‘root’@'localhost’” message while accessing mysql from the command prompt. The error message states that the Mysql password for user ‘root’ is incorrect and need to reset the password using skip-grant-tables option.
ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: NO)
How to reset a Mysql password for ‘root’?
# /etc/init.d/mysql stop
Make sure all the mysql processes are stopped by executing the killall command
# killall -9 mysqld
Next, connect to mysql server using the skip-grant-tables method.
# /usr/bin/mysqld_safe –skip-grant-tables &
now, execute ‘mysql’ and you will be at the mysql prompt
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 23056
Server version: xx.xx-community MySQL Community Edition (GPL)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>
Goto the ‘mysql’ database and update the password for user ‘root’ in the “user” table.
mysql> use mysql;
To set a password, execute
mysql> update user set password=PASSWORD(“passhere”) where user=’root’;
OR to set a blank password, execute the mysql ‘update user’ query
mysql> update user set password=PASSWORD(“”) where user=’root’;
Once done, reload privileges and quit
mysql> flush privileges;
mysql> quit
Now, restart the mysql service
# /etc/init.d/mysql restart
and you should be able to connect mysql server:
# mysql
OR
# mysql -uroot -p
Tags: Access denied for user 'root'@'localhost', Access denied for user (using password: NO), How to reset a Mysql password for 'root'?, mysql update query to reset mysql password, reset mysql password with skip-grant-tables

October 11th, 2011 at 4:56 pm
Thank You soo much!!!!! I have been struggling with this blasted problem for days and now I can finally enter mysql! Such a beautiful and extremely well written tutorial on how to solve this problem!! Whoever you are, THANK YOU!:-)
October 22nd, 2011 at 8:16 am
Welcome