CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
DBI connect failed: Can't connect to MYSQL server on 'localhost'



Mar 1, 2011, 12:29 PM

Post #1 of 1 (665 views)
DBI connect failed: Can't connect to MYSQL server on 'localhost' Can't Post

I am trying to run a perl script to access MySQL a using Perl command line interpreter with additional modules like DBI and DBD-mysql on windows 7. But I am getting the following error message.

DBI connect ('SEO: host=localhost', 'wdbm', ...) failed: Can't connect to MySQL server on 'localhost' (10061) at line 29

Following is the script

use DBI; 
my($localHostname) = hostname;
my($host) = "localhost";
my($database) = "SEO";
my($user) = "hardiboy";
my($pw) = 'abcd123';

my($basePath) = dirname(__FILE__);

switch($localHostname) {
case '' {
$user = 'hardiboy';
$pw = 'abcd123';

//line 29
my($dbh) = DBI->connect("DBI:mysql:$database;host=$host", $user, $pw);

One important thing to note here is that the script works absolutely fine when I run it from rackspace server but I want to run the file locally.

Also I would like to know if a local script can access the MySQL database using the MYSQL config variables used when running the script from server?? In other words, can the local script access database that is on the remote server/remotely setup?? (I guess this mite be the problem but not sure). If the answer is NO then how can I access the database which is not locally setup.

I would be thankful if anyone can provide me with the solution to this problem

Thanks in Advance

(This post was edited by hardik.mehta.b on Mar 1, 2011, 12:30 PM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives