Subject: | "host=localhost" seems to ignore TCP and goes direct to UNIX socket |
The DSN of
DBI->connect( "DBI:mysql:host=127.0.0.1;port=12345" )
works as you'd expect; namely, connecting to the given TCP port. But the
equal-looking
DBI->connect( "DBI:mysql:host=localhost;port=12345" )
seems to ignore TCP entirely, and attempt to connect directly using the
UNIX socket. I tried stracing them:
$ strace perl -e 'use DBI; DBI->connect(
"DBI:mysql:host=127.0.0.1;port=12345" );'
...
connect(3, {sa_family=AF_INET, sin_port=htons(12345),
sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ECONNREFUSED (Connection refused)
$ strace perl -e 'use DBI; DBI->connect(
"DBI:mysql:host=localhost;port=12345" );'
...
connect(3, {sa_family=AF_FILE, path="/var/run/mysqld/mysqld.sock"}, 110) = 0
For reference:
Linux debian/testing running on i686
$ perl --version
This is perl, v5.8.8 built for i486-linux-gnu-thread-multi
$ perl -MDBD::mysql -e 'print $DBD::mysql::VERSION'
3.0008
$ apt-cache depends libdbd-mysql-perl
...
Depends: libmysqlclient15off
$ dpkg -l libmysqlclient15off
ii libmysqlclient15off 5.0.30-1 mysql database
client library
--
Paul Evans