Posted on 2007-07-02 18:43:37-07 by regan
Changing the default socket file
Hi, I am using DBIx-DWIW to connect to a local MySQL server and purge binary logs. The script I use was originally tested on a server that used /var/lib/mysql/mysql.sock as the socket file. But I moved the script to a newer server that uses /tmp/mysql.sock. Is there a way I can change the default socket file name that is used when I create a connection? Here is how I connect in my script:
my $connection = DBIx::DWIW->Connect( DB => "<database name>", User => "<user>", Pass => "<password>", Host => 'localhost', );
On the system using /tmp/mysql.sock, I get an error saying that /var/lib/mysql/mysql.sock does not exist. I'm trying to find a way I can have it default to /tmp/mysql.sock. I tried connecting like this:
my $connection = DBIx::DWIW->Connect( DB => "<database>", User => "<user>", Pass => "<password>", Host => 'localhost', Socket => "/tmp/mysql.sock );
But it doesn't solve the issue. In the documentation, there is a listing for a "Socket" parameter that can be set, but it also says "Not Implemented." Nevertheless, I tried to add that to my connection and nothing happens. If I use a valid hostname or IP address rather than "localhost" it works just fine, since it just connects to port 3306, but I would rather connect via a socket file. Can anyone tell me what I need to do to make this work? Thanks! -Rob
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.