加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Perl中DBI和DBD-mysql模块的安装

发布时间:2020-12-16 00:11:34 所属栏目:大数据 来源:网络整理
导读:一、DBI的安装 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 二、DBD的安装? yum -y intall ? mysql-devel 注意mysql的环境变量,若没有则用

一、DBI的安装
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

二、DBD的安装?
yum -y intall ?mysql-devel
注意mysql的环境变量,若没有则用 添加/usr/binl/mysql到环境变量PATH中?
PATH/usr/binl/mysql:$PATH;

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

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


测试连接:

#!/usr/bin/perluse 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 todatabase ". 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;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读