RE: Problem Connecting to MySQL Database
"Eric Robertson" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.active-perl |
|---|---|
| Message-ID | <A8ABEA56D7924E8AAB876414C65FD6E0@macbookXP> |
On Mon, Sep 27, 2010 at 3:06 AM, Eric Robertson <[email protected]> wrote: I'm using a MacBook Pro running OS X 10.6.4 and I installed ActiveState Perl - I'm using version 5.8.8 at the moment. I did this to make it easier to install some of the modules I wanted but I'm not sure I wouldn't have been better just to use the Perl that comes with the Mac OS! The problem I have is that I can't connect to a MySQL database that I have on the MacBook, set up using MAMP PRO. When I was running everything under Windows I used to have the DBD::mysql driver installed but this doesn't seem to be available for this build so I'm using DBD::mysqlPP which I assume should work in the same way. However the connection string fails when I try to connect using the following: $dsn = "DBI:mysqlPP:host=localhost:database=$database"; $dbh = DBI->connect($dsn, $username, $database, { RaiseError => 0, PrintError => 0}) || ($error = "Got error '$DBI::errstr' when connecting to $dsn\n"); and the error message is: Got error 'Couldn't connect to localhost:3306/tcp: IO::Socket::INET: connect: Connection refused at /Users/(myname)/Library/ActivePerl/lib/DBD/mysqlPP.pm line 109' when connecting to DBI:mysqlPP:host=localhost:database=$database. I've checked that I was using the correct username and password, setting up and trying different ones, but without success. I have a feeling that I read somewhere that there was a problem using Perl to connect to a database set up under MAMP but can't recall what the problem was. Can anyone suggest why this is not working. Eric Robertson _____ From: Tim Bolshaw [mailto:[email protected]] Sent: 27 September 2010 16:02 To: Eric Robertson Subject: Re: Problem Connecting to MySQL Database $dsn="DBI:mysqlPP:host=localhost;database=$database"; (i.e, replace colon with semicolon after localhost) -- Tim Bolshaw [email protected] Mobile: +66-(0)87 072 5009 Tim I'm afraid this didn't work - I got the same error message. In fact I had tested the connection string with the colon on the live server and this worked OK but I need to use my own server for testing so that I can debug my code in Komodo. Eric. _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs