mysql 无法停止和启动,状态一直是 Active: deactivating (stop-sigterm)

问题

本想设置一下mysql log 日志时间,修改了 my.inf 之后, restart mysqld 一直起不来,查看服务状态,一直是 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).

才想起来,原来是我设置 mysql 日志格式造成的 ?

去掉这一行设置

复制代码
# vim /etc/my.cnf

# wzh 20230817
# default-time-zone='Asia/Shanghai'

现在是这样子

复制代码
# vim /etc/my.cnf
...
# wzh 20230817
# default-time-zone='Asia/Shanghai'
explicit_defaults_for_timestamp=true
log_timestamps=SYSTEM

另外日志中出现 " ... Security ... " ,安装完 centos 7 虚拟机,一直没有关闭 Selinux ! 手动关掉后,reboot!

总结:

突然出现奇怪问题的时候,先看服务状态,再看 log ,想象自己修改过什么配置

本次问题原因在于: default-time-zone='Asia/Shanghai'

相关推荐
hzp6664 分钟前
doris学习6:参数调优
数据库·doris·参数·数据库调优
盟道科技43 分钟前
小程序电商订单超时自动取消的三种实现方案:定时扫描、Redis 过期监听、延迟消息对比与生产落地
数据库·redis·小程序
剑锋所指,所向披靡!1 小时前
MySQL存储引擎
数据库·mysql
reasonsummer1 小时前
【办公类-146-05】20260901《一分园、二分园四大教育》(优化版:标题excle+复制AI文字+Python占位符录入)
开发语言·数据库·c#
2301_800954991 小时前
关系型数据库与非关系型数据库详解
数据库·nosql
崖边看雾1 小时前
MySQL——SQL 经典练习题:学生选课成绩查询(附详细注释)
大数据·数据库·sql·mysql
众壹新能源科技1 小时前
经营口径与运维口径不一致时,发电量报表怎么对账
运维·数据库·人工智能
jyOverQ1 小时前
MySQL 索引为什么能加快查询?B+Tree 到底是什么?
数据库·mysql
天天进步20152 小时前
Pixelle-Video 源码解析 #17:TTS 语音生成:Edge-TTS、Index-TTS 如何接入?
前端·数据库
鸽芷咕2 小时前
异构数据同步,凭什么敢说数据不丢?——拆解金仓KFS的全周期一致性校验
数据库