MySQL: ERROR 1045 Access denied for user ‘root’@’localhost’ (using password: YES)

Posted on September 11, 2009


This error message indicates that the MySQL database is not set to receive a root connection from localhost, which is very hilarious issue. The only way I can fix this issue is by resetting the root permission of the MySQL database. So, the answer to that how I do that is at this page.

root@ubuntu:/# ps -ef | grep mysql
root     10993     1  0 Jun03 ?        00:00:04 /bin/sh /usr/bin/mysqld_safe
root     26946 26932  0 21:14 pts/0    00:00:00 grep mysql
root@ubuntu:/# kill -9 10993

Create a mysql-init file, containing these following lines.

UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';

And then run the mysql with the mysql-init file.

root@ubuntu:/# mysqld_safe --init-file=/home/xxxxx/mysql-init &
[1] 26953

Now the second question is why this happens? I don’t understand why…

Posted in: MyWay, Technology