码迷,mamicode.com
首页 > 数据库 > 详细

PERL-MYSQL

时间:2015-09-30 01:15:04      阅读:271      评论:0      收藏:0      [点我收藏+]

标签:perl-mysql

####1 安装
wget http://www.cpan.org/modules/by-module/DBI/DBI-1.623.tar.gz
tar -zxvf DBI-1.623.tar.gz
cd DBI-1.623
perl Makefile.PL
make
make install

wget http://www.cpan.org/modules/by-module/DBD/DBD-mysql-4.022.tar.gz
tar zxf DBD-mysql-4.022.tar.gz
cd DBD-mysql-4.022
perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config
make && make install


####2 测试
#!/usr/bin/perl -w
use strict;
use DBI;

my $dbname="test";
my $location="110.110.110.1";
my $port="3306";
my $database="DBI:mysql:$dbname:$location:$port";
my $dbh = DBI->connect($database,"yeqing","yeqing123456");

my $sth = $dbh->prepare ("select * from test.group");
   $sth->execute();
   while (my @row = $sth->fetchrow_array()) {
      print "=====> @row <=========\n";
   }
   $sth->finish();
   $dbh->disconnect();

本文出自 “技术屌丝” 博客,谢绝转载!

PERL-MYSQL

标签:perl-mysql

原文地址:http://yeqing.blog.51cto.com/3159086/1699277

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!