2 messages in com.mysql.lists.perlunable to connect to database
FromSent OnAttachments
Jason Errol Draut23 Jul 1999 15:41 
Jochen Wiedmann26 Jul 1999 02:19 
Subject:unable to connect to database
From:Jason Errol Draut (dra@fas.harvard.edu)
Date:07/23/1999 03:41:36 PM
List:com.mysql.lists.perl

I tried the following perl script and got the following error message:

#!/usr/bin/perl use DBI; $user = "root"; $pswd = ''; $options = "localhost"; $driver = "mysql"; $database = "carstuff"; $dsn = "DBI:$driver:database=$database:$options"; $car_dbhand = DBI->connect($dsn,$user, $pswd)|| die("Connect error: $DBI::errstr");

Died here with error string: Can't connect to local MySQL server at car1.pl line 10

I have created the database carstuff in mysql, which is up and running, and I have a user "root" on host "localhost" with a blank password in the "user" table of the mysql database.

I don't know if I need a port number or something else in my connect function call's "$dsn", but if so I don't know what the port number is or anything else for that matter. There are also no environment variables like DBI_DSN or DBI_DRIVER according to the output of

bash> env

I'm not sure if I need to do something else to install the mysql module, but mysql is one of the available drivers according to

DBI->available_drivers()

and it wasn't before installing the module.

DBI->data_sources($driver = "mysql")

returns no data_sources, although while in mysql there are several databases including "carstuff" and "mysql" as well as others I'd created experimentally...

Any help with connecting to databases from perl using DBI would be greatly appreciated!