mySQL



Please choose the following question.

  1. What is the name of my mySQL database?
  2. How I can query my mySQL database directly for debugging purposes?
  3. Is there a perl API for mySQL?

What is the name of my mySQL database?

Your mySQL database name is the same as your account name.
 
 

How I can query my mySQL database directly for debugging purposes?

Telnet to the server and log in using your account name and password. It will be the password that was assigned to your account when the mySQL database was created. Then invoke the mySQL monitor with the following command:

 /usr/local/bin/mysql --user=youracct -p youracct

 Where youracct is your account name.
 
 

Is there a perl API for mySQL?

The mysql perl API which comes with mysql is installed.

Here is a quick demonstration of a generic query:

        use Mysql;

        if ( ! ( $gDBH = Mysql->Connect("servername",
                "database","passwd","user") ) )
        {
                die "SQL Error: $Mysql::db_errstr";
        }

        my $sth = $gDBH->query( "select * from tablename" );

        if ( ! defined $sth )
        {
                die "SQL Error: $Mysql::db_errstr";
        }

        for (;;)
        {
                my %hash;
                last if ! ( %hash = $sth->FetchHash() );

                foreach $key ( sort keys %hash )
                {
                        printf( "%16s: %s\n", $key, $hash{$key} );
                }

                print "\n";
        }