mysql clients ignore port specification when connecting to "localhost"

Bug #241802 reported by Derek Price
6
Affects Status Importance Assigned to Milestone
mysql-admin (Ubuntu)
Invalid
Undecided
Unassigned
mysql-dfsg-5.0 (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: mysql-admin

I can duplicate this with all of mysql, mysqldump, and the mysql-admin GUI on 8.04LTS. This is not the behavior I am used to from the same applications on 6.06LTS or the Windows ports of the same applications.

I normally create an SSH tunnel to a remote (6.06LTS) server where I run a MySQL server (via `ssh -L localhost:33060:localhost:3306'). I also run a local (8.04LTS) MySQL server.

When I specify a host of "localhost" and a port of "33060" to any of mysql, mysqldump, or mysql-admin, the client will attach to the local instance of MySQL server instead of the tunnel to the remote instance, yet when I connect directly to 127.0.0.1, the connection works (I can also work around this by defining some other alias for 127.0.0.1 in /etc/hosts and using it). In the following transcript, note the local MySQL instance is hardy's version 5.051a-3ubuntu5.1 and the remote instance is dapper's version 5.0.22-Debian_0ubuntu6.06.9-log.

derek@jor-el:~$ mysql -h localhost --port=33060 -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 32
Server version: 5.0.51a-3ubuntu5.1 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> quit
Bye
derek@jor-el:~$ mysql -h 127.0.0.1 --port=33060 -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 493390
Server version: 5.0.22-Debian_0ubuntu6.06.9-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> quit
Bye
derek@jor-el:~$ telnet localhost 33060
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
M
5.0.22-Debian_0ubuntu6.06.9-logO�e\ypDAXy,�!xpHUQy,mc(9)Connection closed by foreign host.
derek@jor-el:~$

Revision history for this message
hads (hads) wrote :
Revision history for this message
Derek Price (derek-ximbiot) wrote :

Thanks for the link. I added a comment to the MySQL not-a-bug. I had to agree with one of the previous posters that the current behavior is quite insane.

It does sound like a work-around for at least some clients is to put "protocol=tcp" in the [client] section of my.cnf (I confirmed that this works for mysql & mysql-admin, but the mysql bug mentions that some PHP clients won't notice that). I think it would be much better to push this upstream if the MySQL team regains its senses, but for now, maybe adding that line to the Ubuntu my.cnf would be a good idea? My feeling is that it is better not to cause connection errors and let the performance tuners figure out that they should specify the socket protocol for connections to localhost.

Mathias Gug (mathiaz)
Changed in mysql-dfsg-5.0:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Koen (koen-beek) wrote :

this is not a bug in mysql-admin

Changed in mysql-admin (Ubuntu):
status: New → Invalid
Revision history for this message
Chuck Short (zulcss) wrote :

This is fixed for lucid in mysql 5.1.

Changed in mysql-dfsg-5.0 (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.