编译安装的mysql5.6.39,安装目录是/usr/local/mysql,启用程序时报错:libmysqlclient.so.16: cannot open shared object file: No such file or directory。检查mysql的.so库文件,发现有libmysqlclient.so.18,而程序启用依赖的mysql库文件是libmysqlclient.so.16。解决办法:
解决思路: 使用yum安装mysql,然后启用libmysqlclient.so.16的库文件! 解决过程: [root@back-server ~]# ldconfig -v |grep mysql ldconfig: /etc/ld.so.conf.d/kernel-2.6.32-696.el6.x86_64.conf:6: duplicate hwcap 1 nosegneg ldconfig: Can't open directory /usr/local/lib/libpcre.so.1: Not a directory /usr/local/mysql/lib: libmysqlclient.so.18 -> libmysqlclient_r.so.18.1.0 libauthmysql.so -> libauthmysql.so.0 [root@back-server ~]# ll /usr/local/mysql/lib/ total 236124 -rw-r--r-- 1 mysql mysql 19528338 Jul 27 11:52 libmysqlclient.a lrwxrwxrwx 1 mysql mysql 16 Jul 27 11:55 libmysqlclient_r.a -> libmysqlclient.a lrwxrwxrwx 1 mysql mysql 17 Jul 27 11:55 libmysqlclient_r.so -> libmysqlclient.so lrwxrwxrwx 1 mysql mysql 20 Jul 27 11:55 libmysqlclient_r.so.18 -> libmysqlclient.so.18 lrwxrwxrwx 1 mysql mysql 24 Jul 27 11:55 libmysqlclient_r.so.18.1.0 -> libmysqlclient.so.18.1.0 lrwxrwxrwx 1 mysql mysql 20 Jul 27 11:55 libmysqlclient.so -> libmysqlclient.so.18 lrwxrwxrwx 1 mysql mysql 24 Jul 27 11:55 libmysqlclient.so.18 -> libmysqlclient.so.18.1.0 -rwxr-xr-x 1 mysql mysql 8864941 Jul 27 11:52 libmysqlclient.so.18.1.0 -rw-r--r-- 1 mysql mysql 213370914 Jul 27 11:55 libmysqld.a -rw-r--r-- 1 mysql mysql 14270 Jul 27 11:51 libmysqlservices.a drwxr-xr-x 3 mysql mysql 4096 Jul 27 11:55 plugin [root@back-server ~]# cat /etc/ld.so.conf ...... /usr/loca/mysql/lib 现在使用yum安装mysql [root@back-server ~]# yum install -y mysql [root@back-server ~]# ldconfig -v |grep mysql ldconfig: /etc/ld.so.conf.d/kernel-2.6.32-696.el6.x86_64.conf:6: duplicate hwcap 1 nosegneg ldconfig: Can't open directory /usr/local/lib/libpcre.so.1: Not a directory /usr/lib64/mysql: libmysqlclient.so.16 -> libmysqlclient.so.16.0.0 libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0 /usr/local/mysql/lib: libmysqlclient.so.18 -> libmysqlclient_r.so.18.1.0 libauthmysql.so -> libauthmysql.so.0 启用libmysqlclient.so.16库文件 [root@back-server ~]# cat /etc/ld.so.conf ..... /usr/lib64/mysql [root@back-server ~]# ldconfig 再次查看 [root@back-server ~]# ldconfig -v |grep mysql ldconfig: /etc/ld.so.conf.d/kernel-2.6.32-696.el6.x86_64.conf:6: duplicate hwcap 1 nosegneg ldconfig: Can't open directory /usr/local/lib/libpcre.so.1: Not a directory /usr/lib64/mysql: libmysqlclient.so.16 -> libmysqlclient.so.16.0.0 libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0