Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Zhiqiang Ye
August 3, 2004, 4:55 am
rate this thread
I encountered this problem:
When I start the mysql daemon using the default configuration( that is ,
don't use $HOME/.my.cnf file)
then mysql's socket is located at /tmp/mysql.sock
And, my perl dbi script can work well.
But if I start the mysql daemon using the $HOME/.my.cnf file ( it specifies
the socket location : $HOME/tmp,
port is 2001 not 3306), mysqld is work at $HOME/tmp/mysql.socket.
At this time, the command line of connecting mysql works OK. (mysql -u
root -p ), it can automatically
find the socket location.
But the perl dbi script doesn't work. It tries to open the socket at
/tmp/mysql.sock, of course , it can
not connect to mysql.
Is there any method to specify the socket's location for perl DBI to find
Thank you very much. The code looks like this:
my $usr = "root";
my $password = "123456";
my $dsn="DBI:mysql:$database; mysql_socket=/home/somebody/tmp/mysql.sock";
my $dbh=DBI->connect($dsn,$usr,$password) or die "$DBI::errstr";
Re: DBI cannot connect to mysql at a specified socket location
> I encountered this problem:
> When I start the mysql daemon using the default configuration( that is ,
> don't use $HOME/.my.cnf file)
> then mysql's socket is located at /tmp/mysql.sock
> And, my perl dbi script can work well.
> But if I start the mysql daemon using the $HOME/.my.cnf file ( it
> the socket location : $HOME/tmp,
totally uninformed guess:
maybe the .my.cnf file does not expand $HOME