dbcli / mycli

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.
http://mycli.net
Other
11.42k stars 661 forks source link

mycli 1.23.0 uses socket when it should be using IP address using -u -p #941

Closed danielhoherd closed 3 years ago

danielhoherd commented 3 years ago

mycli 1.23.0 looks for mysqld.sock when trying to connect via ip address using -u -p syntax, but not when using mysql:// syntax.

$ ip addr show eno1
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether de:ad:be:ee:ff:00 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.7/24 brd 192.168.1.255 scope global eno1
       valid_lft forever preferred_lft forever
    inet6 fe80::baca:3aff:feaa:3374/64 scope link
       valid_lft forever preferred_lft forever

$ mycli -uUSERNAME -pPASSWORD -h 192.168.1.7 DATABASE
[Errno 2] No such file or directory: '/var/run/mysqld/mysqld.sock'

$ mycli mysql://USERNAME:PASSWORD@192.168.1.7:3306/DATABASE
mariadb 10.4.13-MariaDB-1:10.4.13+maria~bionic
mycli 1.23.0
Chat: https://gitter.im/dbcli/mycli
Mail: https://groups.google.com/forum/#!forum/mycli-users
Home: http://mycli.net
Thanks to the contributor - Tyler Kuipers
mariadb USERNAME@192.168.1.7:DATABASE>

The problematic syntax works fine in 1.22.0

$ mycli -uUSERNAME -pPASSWORD -h 192.168.1.7 DATABASE
2021-01-14 17:11:14-0800
mariadb 10.4.13-MariaDB-1:10.4.13+maria~bionic
mycli 1.22.0
Chat: https://gitter.im/dbcli/mycli
Mail: https://groups.google.com/forum/#!forum/mycli-users
Home: http://mycli.net
Thanks to the contributor - Daniel West
mariadb USERNAME@192.168.1.7:DATABASE>

My mariadb server is running on my local IP address, but within docker, so mysqld.sock is not present on the local filesystem, but this would likely apply to other interesting networking situations, such as ssh -L

rolandwalker commented 3 years ago

Hi!

I suspect #931. What happens when you add -P 3306 ?

danielhoherd commented 3 years ago

@rolandwalker Adding -P 3306 succeeds.

rolandwalker commented 3 years ago

Thanks!

So the --socket option broke back when mycli added SSH support. #931 was meant to fix --socket. The patch was picked whole from a downstream packager (MacPorts). I wrongly assumed that it had already been sufficiently tested in the wild, and must be correct.

Will try to address this more carefully today.