問題
本想設(shè)置一下mysql log 日志時間,修改了 my.inf 之后, restart mysqld 一直起不來,查看服務(wù)狀態(tài),一直是 deactivating (stop-sigterm)
# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: deactivating (stop-sigterm) (Result: exit-code)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 1130 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 1031 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
CGroup: /system.slice/mysqld.service
└─1233 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mys...
8月 17 18:27:46 centos-192 systemd[1]: Starting MySQL Server...
8月 17 18:31:04 centos-192 systemd[1]: mysqld.service: control process exit...1
Hint: Some lines were ellipsized, use -l to show in full.
加上 -l
[root@centos-192 ~]# systemctl status mysqld -l
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: deactivating (stop-sigterm) (Result: exit-code)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 1130 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 1031 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
CGroup: /system.slice/mysqld.service
└─1233 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
8月 17 18:27:46 centos-192 systemd[1]: Starting MySQL Server...
8月 17 18:31:04 centos-192 systemd[1]: mysqld.service: control process exited, code=exited status=1
8月 18 06:28:42 centos-192 systemd[1]: Starting MySQL Server...
-- Subject: Unit mysqld.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysqld.service has begun starting up.
8月 18 06:28:53 centos-192 mysqld[2075]: Initialization of mysqld failed: 0
8月 18 06:28:53 centos-192 systemd[1]: mysqld.service: control process exited, code=exited status=1
8月 18 06:29:10 centos-192 systemd[1]: Failed to start MySQL Server.
-- Subject: Unit mysqld.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysqld.service has failed.
--
-- The result is failed.
8月 18 06:29:10 centos-192 systemd[1]: Unit mysqld.service entered failed state.
8月 18 06:29:10 centos-192 systemd[1]: mysqld.service failed.
8月 18 06:29:11 centos-192 systemd[1]: mysqld.service holdoff time over, scheduling restart.
8月 18 06:29:11 centos-192 systemd[1]: Stopped MySQL Server.
-- Subject: Unit mysqld.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysqld.service has finished shutting down.
8月 18 06:29:11 centos-192 systemd[1]: Starting MySQL Server...
-- Subject: Unit mysqld.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysqld.service has begun starting up.
8月 18 06:29:21 centos-192 mysqld[2126]: Initialization of mysqld failed: 0
8月 18 06:29:21 centos-192 systemd[1]: mysqld.service: control process exited, code=exited status=1
沒有看出一個所以然!
查看日志
# head /var/log/mysqld.log
2023-08-11T12:22:52.567256Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-08-11T12:22:55.551353Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-08-11T12:22:56.101603Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-08-11T12:22:56.558025Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: cd6d347e-3841-11ee-9af3-00155d32bd0b.
2023-08-11T12:22:56.616202Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-08-11T12:22:57.763072Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2023-08-11T12:22:57.763093Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2023-08-11T12:22:57.766023Z 0 [Warning] CA certificate ca.pem is self signed.
2023-08-11T12:22:58.002974Z 1 [Note] A temporary password is generated for root@localhost: TD%TZ*jB.7Tk
2023-08-11T12:23:28.164212Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
看到這一條: [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
才想起來,原來是我設(shè)置 mysql 日志格式造成的 ?
去掉這一行設(shè)置
# vim /etc/my.cnf
# wzh 20230817
# default-time-zone='Asia/Shanghai'
現(xiàn)在是這樣子
# vim /etc/my.cnf
...
# wzh 20230817
# default-time-zone='Asia/Shanghai'
explicit_defaults_for_timestamp=true
log_timestamps=SYSTEM
另外日志中出現(xiàn) “ … Security … ” ,安裝完 centos 7 虛擬機,一直沒有關(guān)閉 Selinux ! 手動關(guān)掉后,reboot!
總結(jié):
突然出現(xiàn)奇怪問題的時候,先看服務(wù)狀態(tài),再看 log ,想象自己修改過什么配置文章來源:http://www.zghlxwxcb.cn/news/detail-666899.html
本次問題原因在于: default-time-zone=‘Asia/Shanghai’文章來源地址http://www.zghlxwxcb.cn/news/detail-666899.html
到了這里,關(guān)于mysql 無法停止和啟動,狀態(tài)一直是 Active: deactivating (stop-sigterm)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!