Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've recently upgraded mysql and perl, but I can't get DBD::mysql to work (I've loaded DBD::mysqlPP in the mean time) during the tests I get...
[root@pepe DBD-mysql-3.0002]# make test PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e" " +test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/00base.............ok t/10dsnlist..........DBI connect('test','',...) failed: Access denied +for user 'root'@'localhost' (using password: NO) at t/10dsnlist.t lin +e 45 Cannot connect: Access denied for user 'root'@'localhost' (using passw +ord: NO) Either your server is not up and running or you have no permissions for acessing the DSN DBI:mysql:test. This test requires a running server and write permissions. Please make sure your server is running and you have permissions, then retry.
But....all looks good on the mysql side.
mysql select * from user where user = 'root'; +-----------+------+------------------+-------------+-------------+--- +----------+-------------+-------------+-----------+-------------+---- +-----------+--------------+-----------+------------+----------------- ++------------+------------+ | Host | User | Password | Select_priv | Insert_priv | Up +date_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv +| Process_priv | File_priv | Grant_priv | References_priv | Index_pri +v | Alter_priv | +-----------+------+------------------+-------------+-------------+--- +----------+-------------+-------------+-----------+-------------+---- +-----------+--------------+-----------+------------+----------------- ++------------+------------+ | localhost | root | 742939b941ebef1c | Y | Y | Y | Y | Y | Y | Y | Y +| Y | Y | Y | Y | Y | Y + | | pepe | root | | Y | Y | Y | Y | Y | Y | Y | Y +| Y | Y | Y | Y | Y | Y + | +-----------+------+------------------+-------------+-------------+--- +----------+-------------+-------------+-----------+-------------+---- +-----------+--------------+-----------+------------+----------------- ++------------+------------+ 2 rows in set (0.11 sec)
When I try and run the pure perl version (which installs OK) and run
#! /usr/bin/perl -w use strict; use DBI; my @driver_names = DBI->available_drivers; print @driver_names,"\n"; my %drivers = DBI->installed_drivers; print %drivers, "\n"; my @data_sources = DBI->data_sources('mysqlPP'); print @data_sources,"\n"; my $dbh = DBI->connect('dbi::mysqlPP::test','','');
I get
DBMExamplePFileProxySpongemysqlPP dbi:mysqlPP: Can't connect to data source mysqlPP::test, no database driver specifi +ed and DBI_DSN env var not set at huh.pl line 11
What have I forgot?

Replies are listed 'Best First'.
Re: DBD::msyql tests
by u235sentinel (Hermit) on Mar 09, 2006 at 01:08 UTC
    I'm just getting into this myself so I could be totally wrong but it looks like your "access denied" message is because you are not supplying a password during the test. duckyd mentioned the test doesn't use a password. Your select statement which displays root accounts shows root@localhost has a password assigned. I'm guessing this is the case with your second perl program. Maybe I'm not seeing it but I get the impression you need to supply a password there too.

    Here is what I found on cpan.org about connecting with dbi.
    $dbh = DBI->connect($dsn, $user, $password, { RaiseError => 1, AutoCommit => 0 });
    Try adding that to your connect statement and see if it works. Also, check cpan. You might find what you are looking for here DBI

    If none of this works and if you are brave, you could always setup an account without a password and use that for your test. Better safe than sorry I'd say so try to incorporate the password :-)
Re: DBD::msyql tests
by duckyd (Hermit) on Mar 08, 2006 at 23:19 UTC
    Regarding your DBD::mysql issue, it looks like you do have a password for root from localhost. Can you connect to mysql as root from localhost without providing a password?

    Note that the tests attempt to connect with NO password.