Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

How to connect with remote mySQL DB

by perlisok (Initiate)
on Aug 16, 2012 at 09:31 UTC ( #987717=perlquestion: print w/replies, xml ) Need Help??
perlisok has asked for the wisdom of the Perl Monks concerning the following question:


I am trying to connect with my database with this code:

#!/usr/bin/perl -w use DBI; my $dbh = DBI->connect( "dbi:mSQL//", "sadecki +", "********" );
And it gives me an error:
Can't connect to data source 'dbi:mSQL//' beca +use I can't work out what driver to use (it doesn't seem to contain a + 'dbi:driver:' prefix and the DBI_DRIVER env var is not set) at driv. +pl line 5
Could you help me? I am a beginner with perl & db. Thanks

Replies are listed 'Best First'.
Re: How to connect with remote mySQL DB
by kcott (Chancellor) on Aug 16, 2012 at 09:40 UTC

    DBD::mSQL shows the syntax in the first few lines of the SYNOPSIS.

    Update: Your code shows mSQL but I notice your node title shows mySQL. You'll need to resolve that ambiguity. DBD::mSQL has the syntax for both but DBD::mysql may be more appropriate for you.

    -- Ken

      I see now...

      Ken is right, yes, the real problem is that the line is malformed so the passed driver's name is really mSQL//www.db4free, instead mSQL trying to connect to "http://www.db4free". Try with:

      #!/usr/bin/perl -w use DBI; my $dbh = DBI->connect("dbi:mysql:dbname=aghpisos;host=www.db4free","s +adecki", "***");
Re: How to connect with remote mySQL DB
by DrHyde (Prior) on Aug 16, 2012 at 10:24 UTC
    Where on earth did you get dbi:mSQL// from? I can't see anything remotely like it in the doco for DBI or DBD::mysql. Wherever you got it from is buggy and needs fixing.

      ... or glasses.   ;-)   My damm-fool eye doctor has started writing prescriptions with two lens-powers on it ...

Re: How to connect with remote mySQL DB
by pvaldes (Chaplain) on Aug 16, 2012 at 09:39 UTC


    the name of the driver is misspelled. DBI::mysql is what you want if I'm not wrong

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://987717]
Approved by kcott
What's the matter? Cat got your tongue?...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2017-04-28 23:18 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (531 votes). Check out past polls.