centos8部署MySQL5.7故障集

roc_guo發表於2022-02-19

centos8部署MySQL5.7故障集centos8部署MySQL5.7故障集

問題一:日誌檔案不存在,MySQL無法啟動

錯誤日誌:

[root@confluence packages]# /etc/init.d/mysqld restart
 ERROR! MySQL server PID file could not be found!
Starting MySQL.2022-01-15T03:58:44.753030Z mysqld_safe error: log-error set to '/var/log/mariadb/mariadb_error.log', however file don't exists. Create writable for user 'mysql'.
 ERROR! The server quit without updating PID file (/home/confluence/mysql/mysql_data/confluence.pid).
1.2.3.4.
原因和解決方法:

根據日誌提示,MySQL無法啟動是因為指定的日誌檔案/var/log/mariadb/mariadb_error.log不存在
touch建立/var/log/mariadb/mariadb_error.log,並修改許可權為mysql:mysql,該錯誤解決。

問題二:/etc/my.cnf檔案為空,MySQL無法啟動

錯誤日誌:

[root@confluence packages]# /etc/init.d/mysqld start
Starting MySQL.. ERROR! The server quit without updating PID file (/home/confluence/mysql/mysql_data/confluence.pid).
[root@confluence packages]#

1.2.3.

原因和解決方法:

原因是/etc/my.cnf檔案是空的,什麼配置都沒有。
檢視/etc/my.cnf,檔案沒有配置資料目錄等資訊,檔案內容如下:

[root@confluence mysql]# cat /etc/my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[root@confluence mysql]# 
1.2.3.4.5.6.7.8.9.10.11.12.13.
/etc/my.cnf.d目錄下只存在client.cnf一個檔案,內容也是空的:
[root@confluence mysql]# cat /etc/my.cnf.d/client.cnf 
#
# These two groups are read by the client library
# Use it for options that affect all clients, but not the server
#
[client]
# This group is not read by mysql client library,
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]
[root@confluence mysql]# 
1.2.3.4.5.6.7.8.9.10.11.12.

把/etc/my.cnf檔案補充完整,問題即解決。

問題三:/etc/my.cnf檔案許可權過大導致MySQL無法啟動

錯誤日誌:

[root@confluence etc]# /etc/init.d/mysqld start
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
Starting MySQL.my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
.. ERROR! The server quit without updating PID file (/home/confluence/mysql/mysql_data/confluence.pid).
[root@confluence etc]#
原因和解決方法:

原因是因為/etc/my.cnf檔案是從其它節點拷貝拷貝過來的,上傳後預設的許可權過大。把/etc/my.cnf檔案的許可權改成644,重新啟動MySQL則成功。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69901823/viewspace-2856447/,如需轉載,請註明出處,否則將追究法律責任。

相關文章