Can it be that you are using an old version of DBI where the connect syntax
was
my $dsn = "database=$db;host=$host";
DBI->connect($dsn, $user, $pass, "mysql", {});
?????
Ilya
-----Original Message-----
From: Stefan Antonowicz
To: Hardy Merrill
Cc: [EMAIL PROTECTED]
Sent: 06/28/2001 8:21 AM
Subject: RE: Problems running DBD::mysql
Hi Hardy.
I had neglected to mention that I had tried the format you indicated
earlier
on in the game, but Perl still throws the same error. The perl script
now
reads:
*****
my $dsn = "DBI:mysql:database=$db;host=$host";
my $dbh = DBI->connect("$dsn","$id","$pwd",{ RaiseError => 1, PrintError
=>
0 });
if(!defined $dbh) {
die "Can't connect: $DBI::errstr \n";
}
print "Connected!!\n";
******
=and I continue to get the error:
*****
DBD::mysql initialisation failed: Can't locate object method "driver"
via
package "DBD::mysql" at /usr/lib/perl5/site_perl/5.6.0/i386-linux/DBI.pm
line 526.
*****
If you hear of or can think of anything, please let me know!
Thanks,
Stefan Antonowicz
-----Original Message-----
From: Hardy Merrill [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 28, 2001 8:12 AM
To: Stefan Antonowicz
Cc: [EMAIL PROTECTED]
Subject: Re: Problems running DBD::mysql
Stefan Antonowicz [[EMAIL PROTECTED]] wrote:
> Hello All.
>
> I've searched hi and low, and have come up with nada that can help me.
I'm
> hoping someone out there might have an idea of what's wrong.
>
> I inherited a RH 7 box running Perl 5, specifically a Perl script that
is
> going to query a MySQL database and email users with updates. I
parsed
the
> page down to the basic DBI function, so it looks like this:
> ******
> #!/usr/bin/perl -w
>
> use DBI;
> use strict;
>
> my $db = '*****';
> my $host = 'localhost';
> my $id = '*****';
> my $pwd= '*****';
>
> my $dbh = DBI->connect("DBI:mysql:$db:$host",$id,$pwd);
Looking at the DBD::mysql documentation(by doing perldoc DBD::mysql)
and looking at what worked for me, your connect looks incorrect -
at least I can't find anything in the DBD::mysql perldocs that
looks similar.
I use a connect that looks like this:
-------------------------------------
my $DSN = "DBI:mysql:database=$DB;host=$HOST;port=$PORT";
my $dbh = DBI->connect("$DSN",
"$USER",
"$PASS",
{ RaiseError => 1, PrintError => 0 }
);
Here's what "perldoc DBD::mysql" says about connecting:
-------------------------------------------------------
connect
use DBI;
$driver = "mSQL"; # or "mSQL1"
$dsn = "DBI:$driver:$database";
$dsn = "DBI:$driver:database=$database;host=$hostname";
$dbh = DBI->connect($dsn, undef, undef);
or
*** Since you're using mysql, this is the section that is meaningful ***
$dsn = "DBI:mysql:$database";
$dsn = "DBI:mysql:database=$database;host=$hostname";
$dsn =
"DBI:mysql:database=$database;host=$hostname;port=$port";
$dbh = DBI->connect($dsn, $user, $password);
A database must always be specified.
host
port The hostname, if not specified or specified as
'', will default to an mysql or mSQL daemon
running on the local machine on the default
port for the UNIX socket.
Should the mysql or mSQL daemon be running on
a non-standard port number, you may explicitly
state the port number to connect to in the
hostname argument, by concatenating the
hostname and port number together separated by
a colon ( : ) character or by using the port
argument. This doesn't work for mSQL 2: You
have to create an alternative config file and
load it using the msql_configfile attribute,
see below.
HTH.
--
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com