cpan mysql dbd_Perl中DBI、DBD::mysql模块的安装

使用的软件版本

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

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下载

安装过程:用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:

ed1a47a8b0ae5acf8d209c31c484b2db.gifumper 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 < DBI-VERSION.tar.gz | tar xvf -

This command creates a directory named DBI-VERSION.

Change location into the top-level directory of the unpacked distribution:

shell> 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;

阅读(2393) | 评论(0) | 转发(0) |

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值