遇到问题----------安装DBD:mysql时报错install_driver(mysql) failed: Can't load '/usr/lib64/perl5/site_perl/5.8


安装步骤:Perl安装DBDmysql操作mysql数据库


DBI已经成功安装。


安装完DBD后运行脚本 报错:

install_driver(mysql) failed: Can't load '/usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi/auto/DBD/mysql/mysql.so' for module DBD::mysql: libmysqlclient.so.15 无法打开共享对象文件: 没有那个文件或目录 at /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230.

at (eval 3) line 3
Compilation failed in require at (eval 3) line 3.
Perhaps a required shared library or dll isn't installed where expected
at /home/admin/local/BackupMasterDB.pl line 51




是libs位置指向不正确所致 

已默认的方法在centos6.3 64位操作系统上安装,默认libs会指向/usr/lib64:输出如下: I will use the following settings for compiling and testing:
cflags (mysql_config) = -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -fPIC -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1 embedded (mysql_config) = ldflags (mysql_config) = libs (mysql_config) = -L/usr/lib64 -lmysqlclient -lpthread -lm -lrt -ldl mysql_config (guessed ) = mysql_config nocatchstderr (default ) = 0 nofoundrows (default ) = 0 ssl (guessed ) = 0 testdb (default ) = test testhost (default ) = testpassword (default ) = testsocket (default ) = testuser (guessed ) = root
To change these settings, see 'perl Makefile.PL --help' and 'perldoc INSTALL'.
Argument "6.55_02" isn't numeric in numeric ge (>=) at Makefile.PL line 352, line 138. Checking if your kit is complete... Looks good Using DBI 1.609 (forperl 5.010001 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/auto/DBI/ Writing Makefile for DBD::mysql
实际上/usr/lib64下面并没有libmysqlclient等文件,应当在/usr/lib64/mysql 下面才有,所以我们需要对perl Makefile.PL添加参数如下:

 
perl Makefile.PL --libs="-L/usr/lib64/mysql -lmysqlclient -lpthread -lm -lrt -ldl" 


这样去编译才能正确指向libmysqlclient的路径,能正常安装PERL-DBD-MYSQL 


编译完后 

make

make  install  



如果用以上的方法编辑后仍报该错误   


再调用下面的语句:

错误一看是找不到libmysqlclient.so.15 ,先find吧

# find /usr/ -name "libmysqlclient.so*"                           
/usr/local/mysql/lib/mysql/libmysqlclient.so.15.0.0
/usr/local/mysql/lib/mysql/libmysqlclient.so.15
/usr/local/mysql/lib/mysql/libmysqlclient.so

解决方法:

echo "/usr/local/mysql/lib/mysql/" >>   /etc/ld.so.conf
ldconfig

完成




!!!如果 只执行了

echo "/usr/local/mysql/lib/mysql/" >>   /etc/ld.so.conf 
ldconfig

运行脚本的时候 可能会报错:

Perhaps a required shared library or dll isn't installed where expected.

这就是因为 第一步编译时没指点路径的原因。记得用这句编译

perl Makefile.PL --libs="-L/usr/lib64/mysql -lmysqlclient -lpthread -lm -lrt -ldl" 

你可能感兴趣的:(mysql,perl,DBDmysql)