Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Canot connect to the remote mysql server through those lines

by davidj (Priest)
on Jul 05, 2007 at 03:39 UTC ( #624983=note: print w/ replies, xml ) Need Help??


in reply to Canot connect to the remote mysql server through those lines

Well, the first thing I would do is see if I can connect to the database from the commandline.You know:

mysql -u root -p
Since one of the databases in on your local machine, you should have no problem. If you cannot connect that way, then it is a MySQL issue. If you can connect that way, then its an error in the script. If it is an error in the script, then I would strip it down to the absolute essentials of something like this:
#!/usr/bin/perl use DBI; use strict; my $dbh; my $db='survey'; my $host='localhost'; my $user='root'; my $pw='whatever'; $dbh = DBI->connect("DBI:mysql:$db", $user, $pw) or die "Database conn +ection not made: $DBI::errstr"; print "Woo Hoo! I connected!\n"; exit;
If that works, then I would start rebuilding the cgi script from that point.

All that being said, my guess is that it is a problem with the script since it is unlikely that both MySQL servers you are trying to reach have problems.

By the way Nik, you really need to develop some basic troubleshooting skills.

just my 2 cents,
davidj


Comment on Re: Canot connect to the remote mysql server through those lines
Select or Download Code
Re^2: Canot connect to the remote mysql server through those lines
by Nik on Jul 05, 2007 at 04:29 UTC
    In your code yous et the connection vars but never in the connection statement you specify the host.

    I manages to make it work on localhost by turning this:

    ? DBI->connect('DBI:mysql:e_shop@localhost', 'root', 'supersecret', {R +aiseError=>1})
    to that
    ? DBI->connect('DBI:mysql:e_shop', 'root', 'supersecret', {RaiseError= +>1})
    As you can see i just removed 'localhost' and it works! Is this once again one damn windows error?!

    On the remote server though i still get this error:

    DBI connect('e_shop','root',...) failed: Can't connect to local MySQL +server through socket '/var/run/mysqld/mysqld.sock' (2) at /home/www/ +nikos.varsa.gr/cgi-bin/index.pl line 20
    Remote servr error is still a mystery i guess....
      The Mystery has been solved. All connections tring should have been inside double quotes although in localhost worked no proeblem in anyw ay in remoet server it wasnt supported.

        I think you will be surprised to find that @localhost when evaluated in double quoted strings actually means "the values found in the ARRAY localhost", which at the point you are using it is 'undef'.

        So, all you did was find a new way to specify 'e_shop', which you said does work, as "e_shop(undef)". You have just found a new way to say it the same way. The single quotes were correct and you need to find a different solution.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://624983]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2014-09-16 21:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (48 votes), past polls