Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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:

Hi,

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

#!/usr/bin/perl -w use DBI; my $dbh = DBI->connect( "dbi:mSQL//www.db4free.net/aghpisos", "sadecki +", "********" );
And it gives me an error:
Can't connect to data source 'dbi:mSQL//www.db4free.net/aghpisos' 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

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

    dbi:mSQL

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

Re: How to connect with remote mySQL DB
by kcott (Abbot) 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//www.db4free.net/aghpisos 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 ...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://987717]
Approved by kcott
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2014-07-26 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (177 votes), past polls