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 完成安装; |