Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Hi,

I'm trying to connect to a MySQL database that is located on a server, but I think I am having problems with the connect statement. The program appears to hang (see output; I have to kill the process), so I turned on tracing. My code:

use strict; use warnings; use DBI; my $db = 'homo_sapiens_core_42_'; my $host = '192.168.1.200'; my $user = 'xx'; my $pass = 'yy'; DBI->trace(1); print "HERE\n"; my $dbh = DBI->connect("DBI:mysql:$db;host=$host", $user, $pass, { RaiseError => 1 } ) or die ( "Couldn't connect to database: " . DBI->errstr ); print "DONE\n";
The output:
DBI 1.54-ithread default trace level set to 0x0/1 (pid 25943) at q +uery_ensembl.pl line 23 HERE -> DBI->connect(DBI:mysql:homo_sapiens_core_42_;host=192.168.1.200 +, xx, ****, HASH(0x9fc8c28)) -> DBI->install_driver(mysql) for linux perl=5.008005 pid=25943 ru +id=56 euid=56 install_driver: DBD::mysql version 4.004 loaded from /usr/lib/p +erl5/site_perl/5.8.5/i386-linux-thread-m ulti/DBD/mysql.pm <- install_driver= DBI::dr=HASH(0xa063d18) !! warn: 0 CLEARED by call to connect method

I looked through the DBI documentation and several Tutorials (DBI recipes, The fine art of database programming, Reading from a database, and Tricks with DBI), but I couldn't find anything that seemed to address this issue. I also tried several google searches.

I can connect to the database via the command line, so I don't think it is a problem with the server or the database itself.

$ /usr/local/mysql-standard-5.0.27-linux-i686-glibc23/bin/mysql -u xx +-h HOST -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3100 to server version: 5.0.27-standard Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> mysql> use homo_sapiens_core_42_ Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed [deleted test select query] SELECT query successful.

Your wisdom and insights are appreciated. Thanks.


In reply to Connecting to remote db with DBI by dana

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (3)
    As of 2019-12-08 02:16 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Strict and warnings: which comes first?



      Results (162 votes). Check out past polls.

      Notices?