in reply to Re: DBI mysql connection broke suddenly
in thread DBI mysql connection broke suddenly

It's a long shot (and not really Perl related), but localhost is defined in /etc/hosts with a line like this:

127.0.0.1 localhost
I'm wondering if that file was updated recently on your system, perhaps removing that definition. On my client's machine, it looks like that file hasn't been changed in a while (like, not since I set it up almost five years ago).
-rw-r--r-- 1 root root 187 Feb 4 2018 /etc/hosts

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Replies are listed 'Best First'.
Re^3: DBI mysql connection broke suddenly
by afoken (Chancellor) on Nov 10, 2022 at 20:17 UTC

    Right in principle, but wrong for this special case.

    Long ago, someone has decided that the hostname "localhost" is special for MySQL. It won't be resolved at all, instead it connects via a Unix socket on Unix and via shared memory on Windows. On Windows, the hostnames "." and "" are also special, they use a named pipe instead of shared memory. This is documented e.g. in https://dev.mysql.com/doc/refman/8.0/en/connecting.html, in DBD::mysql and in DBD::MariaDB. If you want to connect to the local machine via TCP/IP, you have to use "127.0.0.1" or "::1".

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)