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.

Operate mysql from command line

Use mysql using command line :

First install mysql client using command line.
apt-get install mysql-client or yum install mysql-client according to your Linux distribution.

Now go on mysql prompt using
$ mysql -h 127.0.0.1

If you want to log-in with root using command line
$ mysql -h 127.0.0.1 -u root

Root's password is blank. If it asks for password, do not write anything, just press Enter key.

$ mysql -h 127.0.0.1 -u root -p


Do not try to log-in with password protected user using command line.

If you try to log-in with password protected user, it gives following error :
ERROR 1045 (28000): Access denied for user 'admin'@'localhost' (using password: YES) 

phpmyadmin error : Script timeout passed

phpMyAdmin: Script timeout passed, if you want to finish import, please resubmit same file and import will resume.





If you are not able to upload large sql files in phpmyadmin because of this error, you need to increase your execution time.

Open config file of your phpmyadmin.

If you are using xampp, you will find the config file inside phpmyadmin directory. complete path : /opt/lampp/phpmyadmin/config.inc.php
If you are using apache2 or httpd
complete path : /usr/share/phpmyadmin/config.inc.php

Add following line in the config file.
$cfg['ExecTimeLimit'] = 0;

Restart Apache & mysql both.

Alternate Solution :
Continue Uploading : If you do not have access to server, you can continue uploading the same gzip, sql, zip, or bzip2 file then the data import will pick up where it left off.