Issue
I have a local database on my debian virtual machine. When I ssh into the machine from a Mac and try the following command
mysql -u root -p
I successfully get connected. However if I try to connect from a GUI client on my Mac with the FQDN of the debian vm I get a ' Connection failed' response.
Also
SELECT host, user, password FROM user WHERE user = 'root';
+-----------+------+----------+
| host | user | password |
+-----------+------+----------+
| localhost | root | |
| (none) | root | |
| 127.0.0.1 | root | |
| ::1 | root | |
+-----------+------+----------+
What might be the issue?
Solution
You have root user with access only from localhost. When you are connecting from ssh - you are connecting locally from debian server. When you are connecting from Mac - this is different host. You need to create user with remote access. For example, to allow access from only your Mac
CREATE USER 'username'@'mac_ip_address'
IDENTIFIED BY 'password';
or to allow access from all hosts
CREATE USER 'username'@'%'
IDENTIFIED BY 'password';
Answered By - Andrew