免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1820 | 回复: 0
打印 上一主题 下一主题

Perl中DBI、DBD::mysql模块的安装 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-09-16 13:08 |只看该作者 |倒序浏览

                                                                使用的软件版本
DBI-1.609.tar.gz
DBD-mysql-4.012.tar.gz
建议使用以上版本搭配,否则可能连接mysql错误
一、DBI的安装
wget http://www.cpan.org/modules/by-module/DBD/DBI-1.609.tar.gz
tar -zxvf DBI-1.609.tar.gz
cd DBI-1.609
perl Makefile.PL
make
make test
make install

二、DBD的安装

注意mysql的环境变量,若没有则用 添加/usr/local/mysql/bin到环境变量PATH中
PATH=/usr/local/mysql/bin:$PATH;
export PATH (mysql的安装路径根据实际情况填写)

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

三、其它可能发生的状况
如果运行某个调用MYSQL数据库的程序时出现如下系统提示:
install_driver(mysql)
failed: Can't load
'/usr/lib/perl5/site_perl/5.6.1/i386-linux/auto/DBD/mysql/mysql.so' for
module DBD::mysql:
/usr/lib/perl5/site_perl/5.6.1/i386-linux/auto/DBD/mysql/mysql.so:
undefined symbol: uncompress at
/usr/lib/perl5/5.6.1/i386-linux/DynaLoader.pm line 206. at (eval 2)
line 3
那么说明DBD::MYSQL未安装成功。
此时将/usr/local/mysql/include/mysql/*
复制到/usr/include/
同时将/usr/local/mysql/lib/mysql/*
复制到/usr/lib/(64位系统/usr/lib64/)
然后使用perl Makefile.PL设置环境,再进行后续的正常安装,就能正确连接到MYSQL数据库。
另解:
WINDOWNS下安装:
DBI-MYSQL下载
http://www.mysql.com/downloads/contrib.html
安装过程:用ppm
ppm> install DBI
ppm> install DBD-MySQL
unix下安装:
perl安装的默认路径:
/usr/local/apache/cgi-bin/
无须配置perl即可运行,必有语句:
#!/usr/bin/perl
print "content-type:text/html","\n\n";
安装DBI
shell> perl -MCPAN -e shell
cpan> install DBI
cpan> install DBD::mysql
The DBD::mysql installation runs a number of tests. These tests require
being able to connect to the local MySQL server as the anonymous user
with no password. If you have removed anonymous accounts or assigned
them passwords, the tests fail. You can use force install DBD::mysql to
ignore the failed tests.
DBI requires the Data:

umper module. It may be installed; if not, you should install it before installing DBI.
It is also possible to download the module distributions in the form of compressed tar archives and build the modules manually. For example, to unpack and build a DBI distribution, use a procedure such as this:
Unpack the distribution into the current directory:
shell> gunzip  cd DBI-VERSION
Build the distribution and compile everything:
shell> perl Makefile.PL
shell> make
shell> make test
shell> make install
The make test command is important because it verifies that the module
is working. Note that when you run that command during the DBD::mysql
installation to exercise the interface code, the MySQL server must be
running or the test fails.
或者直接用port安装:
shell >cd /usr/ports/databases/p5-DBI/
shell >make install
shell >/usr/ports/databases/p5-DBD-mysql/
shell >make install
由于mysql5和以前版本的算法不同,所以
update mysql.user set password = old_password('newpwd')
where host = 'localhost' and user = 'root';
然后flush priviledges;


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/93182/showart_2053611.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP