Ubuntu上使用二进制安装数据库时出现了如下问题:mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
解决方案
查看程序运行所需要的库文件
[21:22:33][root@ubuntu-11-22 ~]# ldd /usr/local/mysql/bin/mysql
linux-vdso.so.1 (0x00007ffe46b89000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff224cb2000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007ff224cad000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff224ca8000)
libncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5 (0x00007ff224c80000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff224a54000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff22496d000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff22494b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff224722000)
libtinfo.so.5 => not found
/lib64/ld-linux-x86-64.so.2 (0x00007ff224cbe000)
[21:22:44][root@ubuntu-11-22 ~]#
通过我们的ldd命令发现未找到 libtinfo.so.5 not found.文件
查询libtinfo.so开头的文件
[21:25:27][root@ubuntu-11-22 ~]# find / -name 'libtinfo.*'
/snap/core20/1974/usr/lib/x86_64-linux-gnu/libtinfo.so.6
/snap/core20/1974/usr/lib/x86_64-linux-gnu/libtinfo.so.6.2
/snap/core20/2182/usr/lib/x86_64-linux-gnu/libtinfo.so.6
/snap/core20/2182/usr/lib/x86_64-linux-gnu/libtinfo.so.6.2
/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
/usr/lib/x86_64-linux-gnu/libtinfo.so.6
[21:25:32][root@ubuntu-11-22 ~]#
发现只有6版本的库,这里我们便有了解决方案,利用我们的软连接让5指向6
创建软连接
这个操作的意思是当需要用到 libtinfo.so.5 时去调用libtinfo.so.6.2
ln -s /usr/lib/x86_64-linux-gnu/libtinfo.so.6.3 /usr/lib/x86_64-linux-gnu/libtinfo.so.5
[21:27:22][root@ubuntu-11-22 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.50 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>