问题一:库文件问题
报错:
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.
问题二:配置问题
登陆时遇到错误:ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
解决:
$ /etc/init.d/mysql.server restart
[ ok ] Restarting mysql.server (via systemctl): mysql.server.service.
如果重启还是没有解决,还有一个原因:
由于修改了mysql配置“/etc/my.cnf”引起的。比如修改了配置文件中“[mysql]”选项下的“socket”参数,而未指定“[client]”、“[mysql]”选项的“socket”参数,导致mysql使用默认的socket文件位置去寻找socket文件,从而导致未找到socket文件而引发此错误。
解决方法: 修改“/etc/my.cnf”配置文件,在配置文件中添加“[client]”选项和“[mysql]”选项,并使用这两个选项下的“socket”参数值,与“[mysqld]”选项下的“socket”参数值,指向的socket文件路径完全一致。如下:
[mysqld]
datadir=/storage/db/mysql
socket=/storage/db/mysql/mysql.sock
...省略n行...
[client]
default-character-set=utf8
socket=/storage/db/mysql/mysql.sock
[mysql]
default-character-set=utf8
socket=/storage/db/mysql/mysql.sock