Error 1045 in Navicat and SQLyog
If you’ve experienced “Access denied” while using Navicat or SQLyog or any other MySQL client, this post is for you.
I’m assuming that the username and password are working fine when you SSH into the machine.
Usually this happens because by default the user only has privileges to access mysql-server on localhost and not via remote. The same user in MySQL has to be given access to both localhost and remote. Here are the steps for Ubuntu:
Run this command to grant access from all machines:
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;Or grant access from a specific IP:
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1111.2222.3333.4444' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;You can run the above command multiple times to grant access from multiple IPs. You can also specify a separate username and password for remote access.
Check the final outcome:
SELECT * FROM information_schema.user_privileges WHERE grantee LIKE "'USERNAME'%";Finally, run:
FLUSH PRIVILEGES;Check the connection – it should work.