设置环境变量
export PERL5LIB=:/redhat/perl/lib64/perl5
安装DBI
tar -xzvf DBI-1.631.tar.gz
cd DBI-1.631
perl Makefile.PL PREFIX=/redhat/perl
make
make test
make install
安装DBD
tar -xzvf DBD-Sybase-1.15.tar.gz
cd /redhat/mahy/DBD-Sybase-1.15
perl Makefile.PL MP_AP_PREFIX=/redhat/sybase/OCS-15_0/perl PREFIX=/redhat/perl
make
make test
make install
脚本:
#!/usr/bin/perl
use strict;
use POSIX qw(strftime);
use DBI;
my $dbh = DBI->connect('dbi:Sybase:server=TESTDB;charset=cp936','USERTEST','USERTEST')|| die "Database connection not made: $DBI::errstr";
my $test_sql = qq{
SELECT count (*) AS num_a,
sum (column_2) AS num_b from TEST_DATA
};
my $sth = $dbh->prepare( $test_sql );
my ($num_a,$num_b);
$sth->execute();
$sth->bind_columns( \$num_a, \$num_b);
while( $sth->fetch() ) {
print $num_a;
print $num_b;
}
$sth->finish();
$dbh->disconnect();
总结:
很多文章都默认以root用户安装
其实生产环境一般都是以非root用户安装软件的,容易产生各种资源权限问题
解决权限环境问题有一个基本的思路,那就是指定安装参数并且设置环境变量
环境变量多数是一些路径