in reply to how to test a connection with mysql db

Hello, here are some things to check :

1) are you sure the mysql server is running? try to connect using the 'mysql' command.

2) double-check your parameters, hostname, port, username and password.

3) try with a simple snippet of code.

4) if it still doesn't work, post your code here.

here's the simplest exemple:
my $dbh = DBI->connect("DBI:mysql:database='database':host=localhost:p +ort=3307,'root','password') or die "can't connect: $!";

Replies are listed 'Best First'.
Re^2: how to test a connection with mysql db
by Anonymous Monk on Jul 22, 2005 at 07:09 UTC
    But what about: how do I know if my connection is still OK ?
    Is there a command to test the connection ? or what is the best way to test this ?

    Thanks
    Luca
      You shouldn't have to worry that much about the connection; simply test the return value of each DBI statement, if it fails, then it MAY be because the connection's lost.
      $dbh->something() or .... # put your error management code here
        What if the sql statement is wrong, than it also fails! Is there a difference between both ? Luca