Centos linux 上安装Perl DBD::mysql驱动,转

来源:http://blog.yunvi.com/html/893.html

Perl连接数据库需要安装DBI模块和相应数据库的DBD驱动,Linux上默认安装的Perl是没有该模块的,所以要手动安装。

另外要注意的是,安裝过程会用到 mysql_config 指令。所以用 源码 安裝 MySQL 则可以正常启动,但如果 MySQL 是用 RPM 安裝,就要确定你有 mysql-devel 套件,沒裝的话可至 MySQL 的下载页面下载你目前版本的「Libraries and header files」。

下载dbd:http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.020.tar.gz

开始安装:

tar zxvf DBD-mysql-4.020.tar.gz
cd DBD-mysql-4.020
perl Makefile.PL --testdb=test --testuser=root --testpassword=123456 --testhost=xyly --with-mysql=/usr/local/webserver/mysql/ --mysql_config=/usr/local/webserver/mysql/bin/mysql_config

###安装的时候要注意设置你的用户名和密码,可以看下help,perl Makefile.PL --help

make
make test
make install
简单的安装就到此为止了,如果是别的系统,请参照官方手册:http://cpansearch.perl.org/src/RUDY/DBD-mysql-