当前位置:   article > 正文

perl DBI mysql包安装详解_perl-dbd-mysql安装包

perl-dbd-mysql安装包
1.安装mysql 并运行

 2.首先安装DBI :

Perl MakeFile.PL

 Make

 Make install

3.DBD-mysql包

#perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config (指定mysql_config位置)

或者:

#perl Makefile.PL -mysql_config=/home/mysql/bin/mysql_config -testuser=root -testpassword=dbadmin
#make   
#make test   //检测安装是否成功,如果在此处有错误提示,则需要做后面的cp 文件的动作   
#make install 

install_driver(mysql) failed: Can't load '/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/mysql/mysql.so' for module DBD::mysql: libmysqlclient.so.12: cannot open shared object file: No such file or directory at /usr/lib/perl5/5.8.5/i386-linux-thread-multi/DynaLoader.pm line 230.
 at (eval 6) line 3
Compilation failed in require at (eval 6) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at /root/mysqlreport line 162

cp文件的动作:

#cp /usr/local/mysql40/include/mysql/* /usr/include/
#cp /usr/local/mysql40/lib/mysql/* /usr/lib/

测试:

首先在test库中创建一个table:

如果能够正确的显示出testuser 那表示安装成功。

create table test(id int,name varchar(30))

然后执行下面的Perl脚本插入一条数据并且查询得到结果:

#!/usr/bin/perl
use DBI;
my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost","testuser","testpassword", {'RaiseError' => 1});   #此处注意下区别
my $rows = $dbh->do("INSERT INTO test (id, name) VALUES (1, 'testuser')");
my $query = $dbh->prepare("SELECT name FROM test");
$query->execute();
while(my $rs = $query->fetchrow_hashref()) {
    print "$rs->{'name'}/n";
}

然后再重新安装DBD: DBD-mysql-4.005

#make clean

#perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config
#make   
#make test   
#make install

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号

        
cppcmd=keepalive&