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'