MySQL permission is denied locally, but can connect remotely

I am trying to connect to my mysql database on a remote server (via ssh) using the command:

mysql -u me -h mydomain.com -p 

But it does not work with ERROR 1045 (28000): Access denied for user .. Error

While

 mysql -u me -h localhost -p 

Job

Now this is due not only to the fact that I do not have permission settings, because the permissions for this database are set for% or any host for my user.

This is confirmed by the fact that I can correctly connect from the local machine to the server using the same user. that is, executing the following command on my local machine:

 mysql -u me -h mydomain.com -p 

So my question is, why is this happening and how can I fix it? Why can't I connect to my mysql server from my server when I use the domain name instead of localhost, even if the permissions are configured to accept connections from any host.

+6
mysql mysql-error-1045 dns permissions
source share
1 answer

This is due to the way MySQL handles permissions.

When you connect from a remote host (or from a local host through an external IP address), it will correspond to the me@ % record ( if there is no specific grant for a specific host, re using!). But when you connect via the loopback interface ("localhost" IP) or socket, it will use the grant me@localhost . So you should have two GRANT PRIVILEGES ; one for me@localhost and one for me@ % .

+16
source share

All Articles