Showing posts with label using password: NO. Show all posts
Showing posts with label using password: NO. Show all posts

Saturday, May 11, 2013

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

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

Solutions:

1) Try to change root's password. But it does let you reach on command prompt. So what will you do? Follow this.

Stop mysql first
$ service mysql stop or $ service mysqld stop

Open mysql in safe mode
$ mysqld_safe --skip-grant-tables &

Login with root
$ mysql -u root

Update root's password.
mysql> use mysql; mysql> update user set password=PASSWORD("testpassword") where User='root';

If it does not give permission to update password then Flush Privileges first.
mysql> FLUSH PRIVILEGES;

Now try to set password again
mysql> update user set password=PASSWORD("testpassword") where User='root'; mysql>quit
Now root's password has been set to testpassword.

Restart mysql and try to log-in as root.

2) Have you tried to set password for root or any individual database in phpmyadmin or using command line? If you have done this, now you are trying to open phpmyadmin or try to log-in using command line and you are getting this error.

Solution : Put the same password in config file of phpmyadmin for same user.

By default root password is blank in config file and it looks like this.
$cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = '';
Now set your password here and it will look like this.
$cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = 'password-goes-here';
Restart mysql.