当前位置:   article > 正文

perl dbi mysql 安装_Perl中DBI和DBD-mysql模块的安装

microdnf install libdbd-mysql-perl

一、DBI的安装

wget 外链网址已屏蔽

tar -zxvf DBI-1.604.tar.gz

cd DBI-1.604

perl Makefile.PL

make

make test

make install

二、DBD的安装

yum -y intall  mysql-devel

注意mysql的环境变量,若没有则用 添加/usr/binl/mysql到环境变量PATH中

PATH/usr/binl/mysql:$PATH;

export PATH (mysql的安装路径根据实际情况填写)

wget 外链网址已屏蔽

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

测试连接:

#!/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;

$sth=$dbh->prepare("select * from infobright_loaddata_status");

$sth->execute;

while (@recs=$sth->fetchrow_array) {

print $recs[0].":".$recs[1].":".$recs[2]."\n";

}

$dbh->disconnect;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/酷酷是懒虫/article/detail/951109
推荐阅读
相关标签
  

闽ICP备14008679号