Z
Zhiqiang Ye
Dear all,
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
mysql.sock?
Thank you very much. The code looks like this:
use strict;
use DBI;
my $database="test";
my $hostname="localhost";
my $cnf_file="/home/somebody/.my.cnf";
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";
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
mysql.sock?
Thank you very much. The code looks like this:
use strict;
use DBI;
my $database="test";
my $hostname="localhost";
my $cnf_file="/home/somebody/.my.cnf";
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";