Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect to the localhost using TCP #1958

Open
yarkm13 opened this issue Jan 21, 2024 · 7 comments
Open

Connect to the localhost using TCP #1958

yarkm13 opened this issue Jan 21, 2024 · 7 comments

Comments

@yarkm13
Copy link

yarkm13 commented Jan 21, 2024

  • Sequel Ace Version Version 4.0.13 Build 20062
  • macOS Version: 14.2.1
  • Processor Type: Apple M1 Pro
  • MySQL Version: MySQL 8.0.35
  • macOS Localization: uk

Description
I'm instructed to use host localhost and port 53322 but not a socket. As I know, 127.0.0.1 and localhost aren't the same from the MySQL GRANT permissions perspective.
Provided MySQL command is

mysql --user myuser --database mydatabase --port 53322 --host localhost --protocol TCP

But using host localhost it will try to connect using socket, even if TCP/IP tab is used. MySQL cli provides an --protocol TCP option to force the use of TCP/IP instead of a socket. It seems it's impossible to achieve that in Sequel Ace.

Steps To Reproduce

  1. Configure MySQL server to listen on 127.0.0.1
  2. Grant permissions to the myuser with the only host localhost
  3. Use localhost as hostname in the Sequel Ace TCP/IP connection tab
  4. Click "Test connection"
  5. See the error "MySQL said: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"

Expected Behaviour
I expect it will use TCP/IP host:port connection, because it's TCP/IP connection tab after all, and for socket connection, there is another tab.

Additional context
Why it's important for me now, it's because Teleport tunnel works that way. To securely use a remote database server and not introduce it to the world I need to use Teleport proxy. A command can be something like that:

tsh proxy db --db-user=myuser --tunnel --port 53322 db-service-name

and its result will be the following

Started authenticated tunnel for the MySQL database "db-service-name" in cluster "teleport.example.com" on 127.0.0.1:53322.

Use the following command to connect to the database or to the address above using other database GUI/CLI clients:
  $ mysql --user myuser --port 53322 --host localhost --protocol TCP

I believe it will be convenient to always use the TCP protocol while using the TCP/IP tab, which is expected, and get rid of that always annoying MySQL magic treating of localhost. And keep the socket tab for those who explicitly want to use sockets.

@Jason-Morcos
Copy link
Member

Jason-Morcos commented Jan 22, 2024

I thought we fixed this ~3 years ago? #765
Not sure why we're having trouble here - the code should explicitly force localhost to be TCP/IP if you have TCP/IP selected
Can we get some screenshots of your connection configuration and the error message?

@yarkm13
Copy link
Author

yarkm13 commented Jan 22, 2024

Maybe I'm reading this error message incorrectly?

Знімок екрана 2024-01-22 о 11 08 27

@yarkm13
Copy link
Author

yarkm13 commented Jan 22, 2024

There are different error messages for 127.0.0.1 and localhost

2024-01-22.11.30.05.mov

@Jason-Morcos
Copy link
Member

It may be possible it's falling back on the socket if it cannot connect via TCP/IP?
Can you try with the correct password and see?

@Behinder
Copy link

Same problem here. I tried as 'root' and defined user - in terminal connection works in Sequel Ace it is not.
Zrzut ekranu 2024-01-27 o 20 18 29
Standard connection, not the socket.

@AndrewLarsen
Copy link

AndrewLarsen commented Feb 22, 2024

Same here

When using the following command in terminal "mysql -uroot" it connects as expected.

Screenshot 2024-02-22 at 09 28 31

But when I attempt to use Sequel Ace it doesn't work. It worked earlier today, but after I restarted mysql service (brew service restart mysql) it stopped working in Sequel Ace but not in terminal.

Screenshot 2024-02-22 at 09 30 05

EDIT
For me this was related to "skip-name-resolve=ON" being enabled in my.cnf, localhost could not be resolved to 127.0.0.1, and when I attempted to use 127.0.0.1 I got an error message saying that the host 127.0.0.1 is not allowed.

Removed "skip-name-resolve=ON" and restarted mysql, and now localhost works as expected.

@Behinder
Copy link

Behinder commented Feb 22, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants