Try something like this:

use DBI;
 

my $driver   = "mysql";
my $server   = "myhost";
my $database = "mydb";
my $url      = "DBI:$driver:$database:$server";
my $user     = "username";
my $pass     = "password";
 

my $dbh = DBI->connect($url, $user, $pass)
                || die "Couldn't connect to database: " . DBI->errstr;

Obviously you don't have to make everything a variable, this is just one
possibility.

---
Tom Crimmins
Interface Specialist
Pottawattamie County, Iowa


-----Original Message-----
From: Gerald Preston
Sent: Monday, January 03, 2005 7:40 PM
To: mysql users
Subject: first time accessing

I am making my first attempt to access MySQL with Perl 

 

#!/perl

use warnings;

use strict;

use dbi;

 

  my $dbh=DBI->connect( 'dbi:MySQL, 'user', 'pass' ) or die "Cannot connect
-> !<br>$DBI::errstr";

 

and I get the following error:

 

Can't connect to data source dbi:MySQL, no data driver specified and DBS_DSN
env var not set

 

Any ideas?

 

 

Thanks,

 

Jerry

 

 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to