MySQL Access Denied due to wrong column name

|
| By Webner

MySQL access Denied for user while Username and password is correct.

I got this error when I named one of my table columns as “order” which is also a mysql keyword. When tried to rename it, I got the following error on execution.

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

Note: This error can occur for multiple reasons other than specified above but the solution is same for most of them.

Solution: First Stop MySQL service using following command:

sudo service mysqld stop

If this command doesn’t work simply kill the service:

Kill -9

Start the mysql without password:

sudo mysqld_safe --skip-grant-tables &

Login to mysql as root:

mysql -u root

Set new password of root:

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

Flush privileges:

FLUSH PRIVILEGES;

Now Restart MySQL Service:

sudo Service mysqld restart

This will fix the issue.

Leave a Reply

Your email address will not be published. Required fields are marked *