I. DBI Installation
Wget http://www.cpan.org/modules/by-module/DBD/DBI-1.604.tar.gz
Tar-zxvf DBI-1.604.tar.gz
CD DBI-1.604
Perl makefile. pl
Make
Make Test
Make install
Ii. DBD Installation
Yum-y intallMysql-devel
Note the MySQL environment variables. If not, add/usr/binl/MySQL to the environment variable path.
Path/usr/binl/MySQL: $ path;
Export path(Fill in the installation path of MySQL according to the actual situation)
Wget http://www.cpan.org/modules/by-module/DBD/DBD-mysql-4.006.tar.gz
Tar-zxvf DBD-mysql-4.006.tar.gz
CD DBD-mysql-4.006
Perl makefile. pl -- mysql_config =/usr/bin/mysql_config
Make
Make Test
Make install
Test connection:
#! /Usr/bin/perl
Use dBi;
$ user = "test";
$ passwd = "test ";
$ DBH = "";
$ DBH = DBI-> connect ("DBI: mysql: Database = test; host = 192.1.1.168; Port = 3306 ", $ user, $ passwd) or die "can't connect to
Database ". DBI-errstr;
$ something = $ DBH-> prepare ("select * From infobright_loaddata_status");
$ something-> execute;
while (@ RECs = $ th-> fetchrow_array) {
Print $ RECs [0]. ":". $ RECs [1]. ":". $ RECs [2]. "\ n";
}< br> $ DBH-> disconnect;