Trubo Linux 10下为Perl安装DBD::Mysql模块

Trubo Linux 10下为Perl安装DBD::Mysql模块

by jondy(jondy@tom.com)

用到以前写的Windows下的perl连mysql的脚本才发现
没有安DBI模块,在Windows下安装模块用PPM就可以了,很方便
而在linux没有ppm这个文件
linux下使用perl -MCPAN来安装模块,具体用法查看帮助
perl -MCPAN -h
perl -MCPAN 初次使用时提示设置,基本上一路回车到选择区域和国家
设置保存在
/usr/lib/perl5/5.8.0/CPAN/Config.pm
设置可以修改此文件或干脆删除它再运行perl -MCAPN -e shell重新设置
下边开始安装
perl -MCPAN -e shell
首先要安装DBI模块,这个在trubolinux10下没问题,
cpan> install DBI
然后安装DBD::mysql模块
cpan> install DBD::mysql
提示出错退出:
t/mysql2.t         255 65280    ??   ??       %  ??
1 test skipped.
Failed 16/18 test scripts, 11.11% okay. 723/730 subtests failed, 0.96% okay.
make: *** [test_dynamic] 错误 2
  /usr/bin/make test -- NOT OK
Running make install
  make test had returned bad status, won't install without force
向上找发现
Can't exec "mysql_config": 没有那个文件或目录 at Makefile.PL line 174.
readline() on closed filehandle PIPE at Makefile.PL line 176.
cpan> q
退出
[root@localhost sources]#vim /root/.cpan/build/DBD-mysql-2.9004/Makefile.PL
输入/mysql_config查找发现
open(PIPE, "mysql_config --$param |");
open(PIPE, "/usr/local/mysql/bin/mysql_config --$param |"); #修改此处,
运行
[root@localhost sources]#cd /root/.cpan/build/DBD-mysql-2.9004
[root@localhost sources]#perl Makefile.PL --h
Usage: perl /root/.cpan/build/DBD-mysql-2.9004/Makefile.PL [options]

Possible options are:

  --cflags=       Use  for running the C compiler; defaults
                         to the value of "mysql_config --cflags"
  --libs=          Use  for running the linker; defaults
                         to the value of "mysql_config --libs"
  --testdb=          Use the database  for running the test suite;
                         defaults to test
  --testuser=      Use the username  for running the test suite;
                         defaults to no username
  --testpassword=   Use the password  for running the test suite;
                         defaults to no password
  --testhost=      Use  as a database server for running the
                         test suite; defaults to localhost.
  --testport=      Use  as the port number of the database;
                         by default the port number is choosen from the
                         mysqlclient library
  --nocatchstderr        Supress using the "myld" script that redirects
                         STDERR while running the linker.
  --nofoundrows          Change the behavoiur of $sth->rows() so that it
                         returns the number of rows physically modified
                         instead of the rows matched
  --ssl                  Enable SSL support
  --help                 Print this message and exit

All options may be configured on the command line. If they are
not present on the command line, then mysql_config is called:

  mysql_config --cflags
  mysql_config --libs
  mysql_config --testdb

and so on. See the INSTALL.html file for details.
按提示输入
[root@localhost sources]#perl Makefile.PL --testuser=root --testpassword=password
输入数据库的用户名和密码
这次没有提示错误,然后输入
[root@localhost sources]#make
[root@localhost sources]#make test
[root@localhost sources]#make install
完成安装;

下边是安装时出现错误的完整信息

Running install for module DBD::mysql
Running make for R/RU/RUDY/DBD-mysql-2.9004.tar.gz
CPAN: Digest::MD5 loaded ok
CPAN: Compress::Zlib loaded ok
Checksum for /root/.cpan/sources/authors/id/R/RU/RUDY/DBD-mysql-2.9004.tar.gz ok
Scanning cache /root/.cpan/build for sizes
Deleting from cache: /root/.cpan/build/Msql-Mysql-modules-1.2219 (11.4>10.0 MB)
Deleting from cache: /root/.cpan/build/Data-Dumper-2.121 (10.7>10.0 MB)
Deleting from cache: /root/.cpan/build/Net-Telnet-3.03 (10.2>10.0 MB)
DBD-mysql-2.9004/
DBD-mysql-2.9004/t/
DBD-mysql-2.9004/t/mysql2.t
DBD-mysql-2.9004/t/akmisc.t
DBD-mysql-2.9004/t/60leaks.t
DBD-mysql-2.9004/t/10dsnlist.t
DBD-mysql-2.9004/t/ak-dbd.t
DBD-mysql-2.9004/t/50chopblanks.t
DBD-mysql-2.9004/t/mysql.t
DBD-mysql-2.9004/t/lib.pl
DBD-mysql-2.9004/t/40blobs.t
DBD-mysql-2.9004/t/40nulls.t
DBD-mysql-2.9004/t/insertid.t
DBD-mysql-2.9004/t/40listfields.t
DBD-mysql-2.9004/t/40bindpar

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值