数据库
首页 > 数据库> > 登录mysqlpxc报错找不到库文件libreadline.so.7

登录mysqlpxc报错找不到库文件libreadline.so.7

作者:互联网

一、环境说明:

本博文的演示环境和上篇博文一致
https://blog.51cto.com/wujianwei/2374588

1.1简述:

基于上篇博文,为了部署mysqlpxc集群环境,需要开启3个vmware虚拟机实例来部署3个mysqlpxc实例。
第一篇博文中在初始化mysqlpxc实例后,登录实例时,报错提示:

[root@pxc01 local]# /usr/local/mysqlpxc/bin/mysql -uroot -p
 mysql: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory
[root@pxc01 local]# ldd /usr/local/mysqlpxc/bin/mysql
ldd: ./mysql: not regular file
[root@pxc01 local]# ldd /usr/bin/mysql
    linux-vdso.so.1 =>  (0x00007ffd38da9000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f91bc012000)
    libreadline.so.6 => not found

找不到库文件 libreadline.so.6,出现这样的问题主要是当时自己在上篇博文的环境中卸载了 readline-6.2-10.el7.x86_64 这个文件导致的找不到 libreadline.so.6 库文件

[root@pxc01 ~]# rpm -qa|grep readline-6.2-10.el7.x86_64
readline-6.2-10.el7.x86_64
[root@pxc01 ~]# rpm -e --nodeps readline-6.2-10.el7.x86_64 

于是重新安装 yum install -y readline-devel readline

[root@pxc01 local]# rpm -qa|grep readline*
readline-devel-6.2-10.el7.x86_64
readline-6.2-10.el7.x86_64

到此处第一篇博文找不到libreadline.so.6库文件的问题才得以解决。

二、解决libreadline.so.7找不到的问题

接下来才是本博文要重点阐述的问题。
当然此问题的引出还是和上一篇的博文分不开的。

2.1环境简单说明:

vmware 虚拟机,系统centos7.2,mysqlpxc 版本5.7.24,二进制版本安装。firewalld 和iptables关闭,selinux关闭。单台虚拟机安装单实例mysqlpxc服务。初始化mysqlpxc 和启动mysqlpxc都是参照上一篇博文https://blog.51cto.com/wujianwei/2374588成功部署。
但是在登录mysqlpxc实例时,依旧报错如下:

[root@pxc02 data]# /usr/local/mysqlpxc/bin/mysql -uroot -p
/usr/local/mysqlpxc/bin/mysql: error while loading shared libraries: libreadline.so.7: cannot open shared object file: No such file or directory
[root@pxc02 mysql3308]# ldd /usr/local/mysqlpxc/bin/mysql|grep 'not found'
    libreadline.so.7 => not found
[root@pxc02 mysql3308]# find / -name 'libreadline.so.7'
[root@pxc02 mysql3308]#
[root@pxc02 mysql3308]# rpm -qa|grep readline*
readline-6.2-9.el7.x86_64

于是换了一种思路来解决此问题。不再采用上篇博文的方式。

2.2 解决过程:

首先尝试 yum install -y readline-devel readline,本以为可以解决然而并无卵用,依然报错

[root@pxc02 mysql3308]# yum install -y readline-devel readline
[root@pxc02 mysql3308]# rpm -qa|grep readline*
readline-devel-6.2-10.el7.x86_64
readline-6.2-10.el7.x86_64
[root@pxc02 mysql3308]#  /usr/local/mysqlpxc/bin/mysql -uroot -p',pL*O3dLkWk)'
/usr/local/mysqlpxc/bin/mysql: error while loading shared libraries: libreadline.so.7: cannot open shared object file: No such file or directory

[root@pxc02 mysql3308]# ldd /usr/local/mysqlpxc/bin/mysql|grep 'not found'
    libreadline.so.7 => not found

于是换了一种思路,尝试×××器上存在的libreadline.so 库文件有哪些?

    [root@pxc02 mysql3308]# find / -name 'libreadline.so*'
/usr/lib64/libreadline.so.6.2
/usr/lib64/libreadline.so
/usr/lib64/libreadline.so.6

[root@pxc02 mysql3308]# ll /usr/lib64/libreadline.so.6
lrwxrwxrwx 1 root root 18 Feb 24 09:33 /usr/lib64/libreadline.so.6 -> libreadline.so.6.2
[root@pxc02 mysql3308]# ll /usr/lib64/libreadline.so.6.2
-rwxr-xr-x 1 root root 285240 Aug  2  2017 /usr/lib64/libreadline.so.6.2

发现源文件是libreadline.so.6.2 ,而libreadline.so.6 这个文件为源文件libreadline.so.6.2创建的软连接

根据下面的库文件的指向,断定后面的文件应该都是源库文件的软连接,而libreadline.so.7 => not found 提示找不到软连接文件的位置,于是猜测要是根据原库文件把这个找不到的软连接文件创建出来,会是一个什么样的效果呢??

[root@pxc02 mysql3308]#  ldd /usr/local/mysqlpxc/bin/mysql
    linux-vdso.so.1 =>  (0x00007ffc45bdf000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f6e54cf4000)
    libreadline.so.7 => not found
    libncurses.so.5 => /lib64/libncurses.so.5 (0x00007f6e54acc000)
    libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f6e548a2000)
    libz.so.1 => /lib64/libz.so.1 (0x00007f6e5468c000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f6e54483000)
    libatomic.so.1 => /lib64/libatomic.so.1 (0x00007f6e5427b000)
    libssl.so.1.1 => /lib64/libssl.so.1.1 (0x00007f6e5400d000)
    libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007f6e53b89000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f6e53985000)
    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f6e53603000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f6e53300000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f6e530ea000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f6e52d29000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f6e554ff000)

于是根据源库文件libreadline.so.6.2 把libreadline.so.7要找的软连接文件创建出来


    [root@pxc02 mysql3308]# ln -sv /usr/lib64/libreadline.so.6.2 /usr/lib64/libreadline.so.7
/usr/lib64/libreadline.so.7 -> /usr/lib64/libreadline.so.6.2

    [root@pxc02 mysql3308]# ll /usr/lib64/libreadline.so.7
lrwxrwxrwx 1 root root 29 Feb 24 09:46 /usr/lib64/libreadline.so.7 -> /usr/lib64/libreadline.so.6.2
[root@pxc02 mysql3308]# find / -name 'libreadline.so*'
/usr/lib64/libreadline.so.7
/usr/lib64/libreadline.so.6.2
/usr/lib64/libreadline.so
/usr/lib64/libreadline.so.6

检测如下:发现不在报错,问题解决。

[root@pxc02 mysql3308]# ldd /usr/local/mysqlpxc/bin/mysql 
    linux-vdso.so.1 =>  (0x00007fffbeb64000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f9cef24a000)
    libreadline.so.7 => /lib64/libreadline.so.7 (0x00007f9cef004000)
    libncurses.so.5 => /lib64/libncurses.so.5 (0x00007f9ceeddc000)
    libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f9ceebb2000)
    libz.so.1 => /lib64/libz.so.1 (0x00007f9cee99c000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f9cee793000)
    libatomic.so.1 => /lib64/libatomic.so.1 (0x00007f9cee58b000)
    libssl.so.1.1 => /lib64/libssl.so.1.1 (0x00007f9cee31d000)
    libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007f9cede99000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f9cedc95000)
    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f9ced913000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f9ced610000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f9ced3fa000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f9ced039000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f9cefa55000)
[root@pxc02 mysql3308]#  /usr/local/mysqlpxc/bin/mysql -uroot -p',pL*O3dLkWk)'
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[root@pxc02 mysql3308]# ldd /usr/local/mysqlpxc/bin/mysql 

总结:发现解决此问题简单了不少。遇到问题一定要先看下报错,做下简单的分析,不要盲目的直接google和百度。要有针对性的解决问题

标签:libreadline,so.1,报错,mysqlpxc,so.6,lib64,root,usr
来源: https://blog.51cto.com/wujianwei/2374900