CentsOS 8正常安装,安装完后配置主机名,IP,上传MySQL 5.7的安装包,解压,配置my.cnf,初始化,启动,一切都比较顺利。
在准备使用中遇到以下两个错误:
1. 库文件缺失
1.1 报错信息
[root@lab2 5.7.33]# bin/mysql -uroot -p
bin/mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
[root@lab2 5.7.33]# bin/mysql -uroot -p
bin/mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
1.2 分析原因
mysql运行时依赖的两个系统库文件libncurses.so.5和libtinfo.so.5不存在,在CentOS 8.0上,采用更新版本的文件。
[root@lab2 lib64]# pwd
/lib64
[root@lab2 lib64]# ls -l libncurse*
lrwxrwxrwx. 1 root root 17 May 10 2019 libncurses.so.6 -> libncurses.so.6.1
-rwxr-xr-x. 1 root root 216912 May 10 2019 libncurses.so.6.1
[root@lab2 lib64]# ls -l libtinfo*
lrwxrwxrwx. 1 root root 15 May 10 2019 libtinfo.so.6 -> libtinfo.so.6.1
-rwxr-xr-x. 1 root root 208616 May 10 2019 libtinfo.so.6.1
1.3 解决方法
通过软链接将mysql运行时依赖的两个库文件分别指向最新版本,如下:
[root@lab2 lib64]# ln -s libncurses.so.6.1 libncurses.so.5
[root@lab2 lib64]# ls -l libncurse*
lrwxrwxrwx. 1 root root 17 Feb 17 05:30 libncurses.so.5 -> libncurses.so.6.1
lrwxrwxrwx. 1 root root 17 May 10 2019 libncurses.so.6 -> libncurses.so.6.1
-rwxr-xr-x. 1 root root 216912 May 10 2019 libncurses.so.6.1
[root@lab2 lib64]# ln -s libtinfo.so.6.1 libtinfo.so.5
[root@lab2 lib64]# ls -l libtinfo*
lrwxrwxrwx. 1 root root 15 Feb 17 05:32 libtinfo.so.5 -> libtinfo.so.6.1
lrwxrwxrwx. 1 root root 15 May 10 2019 libtinfo.so.6 -> libtinfo.so.6.1
-rwxr-xr-x. 1 root root 208616 May 10 2019 libtinfo.so.6.1
1.4 检验结果
[root@lab2 5.7.33]# bin/mysql -uroot -p -S /app/mysql/3307/mysql.pid
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.33
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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>
2. 错误信息无法正常显示
话说上一个坑的问题解决之后,能顺利登录SERVER,想看看数据库情况,又踩了一个坑。
2.1 报错信息
mysql> show databases;
ERROR 1820 (HY000): Unknown error 1820
另外一台mysql server:
mysql> system perror 1820
MySQL error code 1820 (ER_MUST_CHANGE_PASSWORD): You must reset your password using ALTER USER statement before executing this statement.
??为啥这台SERVER错误信息这么精简
2.2 排查过程
首先,检查Error log,发现MySQL Sever在启动中有个相关的Error。
2021-02-17T10:40:32.848707Z 0 [Note] bin/mysqld (mysqld 5.7.33) starting as process 35733 ...
2021-02-17T10:40:32.848943Z 0 [ERROR] Can't find error-message file '/opt/mysql/5.7.30/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
检查发现该文件确实不存在
对比另外一台正常的SERVER,该文件也不存在。说明错误与该文件存在与否不相关。
??为啥
进一步检查配置文件,发现basedir设置有误,配置文件中将basedir设置为:/opt/mysql/5.7.30/ ,而实现安装目录为:/opt/mysql/5.7.33
!! 可能是这里的问题
[root@lab2 5.7.33]# cat my.cnf
[mysqld]
#base settings
basedir = /opt/mysql/5.7.30/
[root@lab2 5.7.33]# ls -l /opt/mysql/5.7.30/
ls: cannot access '/opt/mysql/5.7.30/': No such file or directory
[root@lab2 5.7.33]# cd /opt/mysql/5.7.30/
-bash: cd: /opt/mysql/5.7.30/: No such file or directory
[root@lab2 5.7.33]# pwd
/opt/mysql/5.7.33
2.3 解决问题
修改my.cnf文件中的basedir配置项,将其指向正确的目录,并重启MySQL服务器。
2.4 检验结果
重启MySQL后,检查错误日志,之前的错误信息已不存在。
2021-02-17T11:04:18.785032Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-02-17T11:04:18.785347Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2021-02-17T11:04:18.785532Z 0 [Note] bin/mysqld (mysqld 5.7.33) starting as process 40701 ...
2021-02-17T11:04:18.841237Z 0 [Note] InnoDB: PUNCH HOLE support available
尝试触发一个错误,
mysql> select data;错误信息比较详细,问题解决。
ERROR 1054 (42S22): Unknown column 'data' in 'field list'