http://www.perlmonks.org?node_id=987717

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

Replies are listed 'Best First'.
Re: How to connect with remote mySQL DB
by kcott (Archbishop) 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 ...

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