Can't connect to local MySQL server

Web hosting discussion, programming, and shared and dedicated servers.
15 posts Page 2 of 2
by jond » Thu Aug 04, 2011 1:15 pm
Thanks augie for this explanation of '_' in the DNS protocol - I had no idea!

So back to my error, I hope someone can give me their rendition of the three lines I posted above, which work in their perl program. Surely, the problem must be syntax or path somewhere, thanks :)
by augie » Thu Aug 04, 2011 4:33 pm
jond wrote:So back to my error, I hope someone can give me their rendition of the three lines I posted above, which work in their perl program. Surely, the problem must be syntax or path somewhere, thanks :)
I'm not seeing a problem when I try:

http://sevenhawkswinery.com/db_manager.cgi
by jond » Thu Aug 04, 2011 10:19 pm
Yes, the program works initially to the main menu (before it attempts to 'connect' to the db).

And this is a good point because it means that by then, at least the libraries DBI and DBD::mysql have been loaded, so we can rule out problems from the first two lines of db initialization.

The problem then remains on line 50, where, when choosing a menu option (like 'View the Database'), the following line is called

my $dbh = DBI->connect( $DSN, "jond_winery-all", "882b1d95", { RaiseError => 1 } );
(where $DSN = "DBI:mysql:jond-winery.db.sonic.net")

and bombs. I'm pretty sure the error does not appear later and reverts to that line, as it seems to happen occasionally.

Does anybody connect to this db via perl successfully (please show me your code)?

Thanks for trying :)

ps: I am going to have to solve this soon or will have to sadly move to another server
by augie » Fri Aug 05, 2011 11:20 am
Your DSN is missing the database name.

Check out the code I modified:

http://sevenhawkswinery.com/db_manager-augie.cgi

And here's a proof of concept you can try too:

Code: Select all

#!/usr/bin/perl

use strict;
use warnings;

use DBI;
use Data::Dumper;

my $dbh;
my $DSN = "DBI:mysql:jond_winery:jond-winery.db.sonic.net:";

unless ( $dbh = DBI->connect($DSN, "jond_winery-all", "882b1d95", { RaiseError => 1 }) )
{
        die "Couldn't connect to mysql server: $!\n";
}

my $sth = $dbh->prepare(
                "SELECT last, first, email FROM customers ORDER BY last, first ASC" );
$sth->execute();

my $rows = $sth->fetchall_arrayref();
$sth->finish();

print Dumper($rows);

Also, you should change the DB's password now. :)
by jond » Fri Aug 05, 2011 2:05 pm
Wow, thank you augie :)
15 posts Page 2 of 2

Who is online

In total there are 112 users online :: 0 registered, 0 hidden and 112 guests (based on users active over the past 5 minutes)
Most users ever online was 999 on Mon May 10, 2021 1:02 am

Users browsing this forum: No registered users and 112 guests