List:General Discussion« Previous MessageNext Message »
From:Jeremy Date:April 24 1999 1:38pm
Subject:Re: Getting "Can't connect to local MySQL server (21)" error from
perl script
View as plain text  
On Fri, 23 Apr 1999, Bill Rhodes wrote:

> I have a small problem connecting to a mysql database using perl scripts 
> and the DBI module.  When I try to issue a DBI->connect() from within the 
> script, I get an error (it's below).  I think the problem is that my mysql 

>    $dsn = "DBI:mysql:$database";
> 
>    $dbh = DBI->connect ($dsn,$user,$pass,'');

I wrote a script a few days ago for basically the same purpose
as you.  I just compared it to the lines above, and there is a
small difference.  Here's what I have:

$dsn = "DBI:$driver:database=$database";

$dbh = DBI->connect($dsn, $user, $password);

In the first line, $driver = "mysql" and $database =
the database name, and I think you can figure out
the second line.  I'm new to this MySQL/DBI/CGI stuff
too, so I'm not sure if it makes any difference.  You
might try putting in the "database=" part and see if
that works.

HTH,
Jeremy
-------------------------------------------------------
To automatically retrieve my PGP key via e-mail, send a
blank message with the subject line "fetch pgp key".



Thread
Can't access any of databasesDenis Kotseba21 Apr
  • Re: Can't access any of databasesSasha Pachev24 Apr
    • Re: Can't access any of databasesDarrell Shifflett24 Apr
Re: Can't access any of databasesFred Lindberg24 Apr
  • Re: Can't access any of databasesDarrell Shifflett24 Apr
  • Getting "Can't connect to local MySQL server (21)" error fromperl scriptBill Rhodes24 Apr
    • Re: Getting "Can't connect to local MySQL server (21)" error from perl scriptJeremy24 Apr