darist has asked for the wisdom of the Perl Monks concerning the following question:

Hi there! I want to connect to a MySQL sever with a perl script using named-pipes instead if TCP/IP.
I'm running on windows xp with activeState Perl, using DBD::mysql to make the connection.
I configured the server to enable named-pipes like this on my.ini
socket = C:/temp/mysql.sock enable-named-pipe skip-networking
and this is what my script looks like:
my $dsn = 'DBI:mysql:mydb;mysql_socket=/temp/mysql.sock'; my $db_user_name = 'user'; my $db_password = 'password'; my $dbh = DBI->connect($dsn, $db_user_name, $db_password);
Note: I didn't include the C: in the string because it thinks what comes after the ":" is the host name.
when I run the script I get this:
DBI connect('mydbmysql_socket=/temp/mysql.sock','user',...) failed: Can't connect to MySQL server on 'localhost' (10061) at myscript.pl l +ine 60
Does DBD::mysql support named pipes? Do you know if it understands that "/" is actually "C:\"? If not, how do I tell it to look in C:?

Thanks!
David

Replies are listed 'Best First'.
Re: Connect to MySQL server on Windows using named pipe (perl DBD::mysql)
by umasuresh (Hermit) on Oct 26, 2010 at 18:50 UTC
    Try escaping the ":" c\:\/temp\/mysql.sock

      Hi again!

      Thanks for the reply! Escaping the ":" didn't work... but I think I figured it out...

      I don't really understand it, but it looks like in Windows it doesn't really want a full path, just a name, so I took out the "socket=c:/temp..." from the my.ini file (so it would use the default name for the named pipe, which is "MySQL" from what I've read).

      Then for the connection, I did this:

      my $dsn = "DBI:mysql:database=mydb;host=.";

      ... and it just worked! The mysql program (client that comes with the installation of MySQL) also uses the hostname "." as the way to specify the use of named pipes.

      This syntax worked too:

      my $dsn = "DBI:mysql:mydb:.";
      Thanks, David
Re: Connect to MySQL server on Windows using named pipe (perl DBD::mysql)
by aquarium (Curate) on Oct 27, 2010 at 03:09 UTC
    haven't checked but..does mysql try to use the underlying OS named pipes for this?..as there are implications, with Windows named pipes being a bit different to *nix, most notably being volatile i.e. not sticking around too long.
    the hardest line to type correctly is: stty erase ^H