S
sangeetha
Hi Experts,
I'm new to PERL DBI programming i've writen following perl DBI
program, It seems it is nt able to connect to MySQL.
#!perl
use warnings;
use strict;
use DBI;
my $dbh;
$dbh = DBI->connect('dbi:mysql:test','root','pepsi');
unless ($dbh) {
print "Error opening database: $DBI::errstr\n";
exit ;
}
my $connected = $dbh->ping;
if ($connected and not int($connected)) {
print "ping not implemented by '", $dbh->{driver}->{Name},"'.\n";
} else {
print "Connection is live\n";
}
$dbh->disconnect();
<<<<<<<<<<<<< End Program >>>>>>>>>>>>>>>>>>>>
Output Error message:
DBI connect('test','root',...) failed: Can't connect to local MySQL
server through socket '/tmp/mysql.sock' (2) at db.pl line 10
Error opening database: Can't connect to local MySQL server through
socket '/tmp/mysql.sock' (2)
<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>
Please note i'm able to check my (test) table directly login into
"mysql" by "mysql -u root -p" ... checked "mysqld" is running in
localhost.. MySQL version is "mysql Ver 11.18 Distrib 3.23.56, for
redhat-linux-gnu (i386)".
Tried:
Modified the "/etc/my.cnf" file to point the "socket" file to
"/var/lib/mysql//mysql.sock". for the header of "[client] and
[mysqld]" even now it's not working....
Please point where it goes wrong.
Thanks,
Sangeetha.
I'm new to PERL DBI programming i've writen following perl DBI
program, It seems it is nt able to connect to MySQL.
#!perl
use warnings;
use strict;
use DBI;
my $dbh;
$dbh = DBI->connect('dbi:mysql:test','root','pepsi');
unless ($dbh) {
print "Error opening database: $DBI::errstr\n";
exit ;
}
my $connected = $dbh->ping;
if ($connected and not int($connected)) {
print "ping not implemented by '", $dbh->{driver}->{Name},"'.\n";
} else {
print "Connection is live\n";
}
$dbh->disconnect();
<<<<<<<<<<<<< End Program >>>>>>>>>>>>>>>>>>>>
Output Error message:
DBI connect('test','root',...) failed: Can't connect to local MySQL
server through socket '/tmp/mysql.sock' (2) at db.pl line 10
Error opening database: Can't connect to local MySQL server through
socket '/tmp/mysql.sock' (2)
<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>
Please note i'm able to check my (test) table directly login into
"mysql" by "mysql -u root -p" ... checked "mysqld" is running in
localhost.. MySQL version is "mysql Ver 11.18 Distrib 3.23.56, for
redhat-linux-gnu (i386)".
Tried:
Modified the "/etc/my.cnf" file to point the "socket" file to
"/var/lib/mysql//mysql.sock". for the header of "[client] and
[mysqld]" even now it's not working....
Please point where it goes wrong.
Thanks,
Sangeetha.