Error 1045 code example
Example 1: ERROR 1045 (28000): Access denied for user 'ananyapam'@'localhost' (using password: NO)
sudo mysql -u root -p
Example 2: windows error 1045 (28000): access denied for user 'root'@'localhost' (using password: yes)
update user set authentication_string=password('my_password') where user='root';
Example 3: mysql error 1045
mysql> SELECT Host, User, authentication_string, PASSWORD('forgotten') FROM mysql.user WHERE User='nonexistant';
+-------------+-------------+-------------------------------------------+-------------------------------------------+
| Host | User | authentication_string | PASSWORD('forgotten') |
+-------------+-------------+-------------------------------------------+-------------------------------------------+
| 192.168.0.1 | nonexistant | *AF9E01EA8519CE58E3739F4034EFD3D6B4CA6324 | *70F9DD10B4688C7F12E8ED6C26C6ABBD9D9C7A41 |
| % | nonexistant | *AF9E01EA8519CE58E3739F4034EFD3D6B4CA6324 | *70F9DD10B4688C7F12E8ED6C26C6ABBD9D9C7A41 |
+-------------+-------------+-------------------------------------------+-------------------------------------------+
2 rows in set, 1 warning (0.00 sec)