I am trying to connect Mysql5.1 from Perl 5.8.8 on RHEL5 as follows:

$dsn="DBI:mysql:database=mysql";
$dbh=DBI->connect($dsn, 'root', 'root', 'mysql',{RaiseError => 1});

When I try to run perl containing above connection, it gets connected to Mysql and fetches data but displays following warning.

DBI->connect using 'old-style' syntax is deprecated and will be an error in future versions

What can be done to remove this warning?

Thanks and Regards

I don't know, you can try www.perlmonks.com or ask on the dbi modules mailing list (see the DBI module for details)

You need to remove the 'mysql' parameter from connect. Should look something like this:

use DBI;

$dsn="DBI:mysql:database=mysql";
$dbh=DBI->connect($dsn, 'root', 'root', {RaiseError => 1});

You can do this:

no warnings ;
no warnings 'all' ;

You need to remove the 'mysql' parameter from connect. Should look something like this:

use DBI;

$dsn="DBI:mysql:database=mysql";
$dbh=DBI->connect($dsn, 'root', 'root', {RaiseError => 1});

Thanks it is working fine now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.