On Mon, Mar 10, 2003 at 11:32:06AM -0600, Paul DuBois wrote: > Whether it's a feature or not, it's not always so easy to figure out > what to do. If you specify -h localhost, it can be argued that you > really want the socket even if you specify the port. It can be > argued conversely that if you specify the port, you should use TCP/IP > even if you specify -h localhost. > > That is, if the user specifies both, it's ambiguous what the user really > wants.
But "localhost" is a DNS name that only happens to resolve to 127.0.0.1. MySQL breaks this DNS abstraction by treating "localhost" as a keyword, different from 127.0.0.1, which goes against the principle of least surprise. (It confused me, anyway.) I think it would have been less confusing to treat "localhost" the same as its resolved IP address, and decide whether to use a local socket vs. a port number on the basis of a different argument (-l for local, perhaps, which would be the default when connecting to 127.0.0.1 (or localhost, or any other name that resolved to this IP)). Wild speculation: The current design was chosen back when MySQL didn't have different sections in /etc/my.cnf, so the port specification for the server was also used for the client. In that case the client usually read a port specification (in /etc/my.cnf), but in the common case the client wouldn't obey it, which typically did the right thing. (Now that there are separate [client] and [server] sections in my.cnf things are less jumbled.) The client could be made to obey a command-line argument, while still silently ignoring the my.cnf argument. (That's what my patch did.) It's not just the mysql client, it's the client library, which is what bit us. You specify a port in the DBI->connect() routine as something like ';host=localhost;port=2000' and it's silently ignored there too. I'm very glad that ssh no longer (as of three years ago!) forwards externally-connected-to ports by default. --Pete --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php