Reputation: 51
hey guys so I'm having this weird error. So I've created a tunnel from a remote computer onto mine. SQL runs on the remove PC on port 3306 My tunnel config goes
ssh -N -L 33307:127.0.0.1:3306 something.something.com
This means that effectively traffic from port 3306 of remote pc is being directed to my 33307 127.0.0.1 port of my Mac. Now the problem is
mysql -u user -phfkahfkz -p 33307
DOES NOT work, gives a user@localhost error
mysql -u user -phfkahfkz -p 33307 -h 127.0.0.1 works fine
my host file already had
127.0.0.1 localhost
I tried adding
localhost 127.0.0.1
I'm clueless as to whats happening
Another question, so when I effectively create a tunnel, I don't need sql to be install on my Mac right? I though that it might be trying to connect to my local copy of sql so I stopped SQL from running locally and
mysql -u user -phfkahfkz -p 33307
mysql -u user -phfkahfkz -p 33307 -h localhost
both give a Can't connect to local MySQL server
mysql -u user -phfkahfkz -p 33307 -h 127.0.0.1
works fine with local sql service stopped
Upvotes: 1
Views: 569
Reputation: 562861
In MySQL, localhost is different from 127.0.0.1.
Localhost is treated specially, meaning it does not use TCP/IP at all, but tries to communicate with a local instance of MySQL via a socket file.
You'll have to use 127.0.0.1 explicitly.
Read https://dev.mysql.com/doc/refman/5.7/en/connecting.html for details.
Upvotes: 1