開始使用:cpan DBD::mysql 命令來安裝該模組
由於是編譯的版本的SQL版本,已經在/etc/profile 中修改:export PATH=/usr/local/mysql/bin:$PATH
擔心找不到mysql lib檔案。
報錯如下:
# Tried to use 'DBD::mysql'.
# Error: Can't load '/root/.cpan/build/DBD-mysql-4.022/blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: libmysqlclient.so.16: 無法開啟共用對象檔案: 沒有那個檔案或目錄 at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/DynaLoader.pm line 230.
# at (eval 6) line 2
# Compilation failed in require at (eval 6) line 2.
# BEGIN failed--compilation aborted at t/00base.t line 21.
FAILED--Further testing stopped: Unable to load DBD::mysql
make: *** [test_dynamic] 錯誤 9
/usr/bin/make test -- NOT OK
Running make install
make test had returned bad status, won't install without force
[root@localhost dbdata_backup]# perl -MCPAN -e shell
Terminal does not support AddHistory.
cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support available (try 'install Bundle::CPAN')
解決方式:
shell>perl -MCPAN -e shell
cpan> install DBI
cpan> install DBD::mysql安裝成功。
手工安裝DBD安裝技巧:
注意mysql的環境變數,若沒有則用 添加/usr/local/mysql/bin到環境變數PATH中
PATH=/usr/local/mysql/bin:$PATH;
export PATH (mysql的安裝路徑根據實際情況填寫)
wget http://cpan.perl.org/modules/by-module/DBI/DBI-1.601.tar.gz
tar -zxvf DBD-mysql-4.006.tar.gz
cd DBD-mysql-4.006
perl Makefile.PL –mysql_config=/usr/local/mysql/bin/mysql_config
make
make test
make install