标签:sys bin success exp 二次 tps 安装 文件丢失 safe
安装的mysql每次重启后报错
###################################################
Redirecting to /bin/systemctl start mysql.service
Job for mysqld.service failed because the control process exited with error code.
See "systemctl status mysqld.service" and "journalctl -xe" for details.
##################################################
查看服务运行信息
systemctl status mysqld.service
##################################################
● mysqld.service - LSB: start and stop MySQL
Loaded: loaded (/etc/rc.d/init.d/mysqld; generated)
Active: failed (thawing) (Result: exit-code) since Thu 2021-04-08 23:22:55 PDT; 6min ago
Docs: man:systemd-sysv-generator(8)
Process: 13546 ExecStop=/etc/rc.d/init.d/mysqld stop (code=exited, status=0/SUCCESS)
Process: 33545 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE)
Apr 08 23:22:54 primary systemd[1]: Starting LSB: start and stop MySQL...
Apr 08 23:22:55 primary mysqld[33545]: Starting MySQL. ERROR! The server quit without updating PID file (/var/run/mysqld/mysqld.pid).
Apr 08 23:22:55 primary systemd[1]: mysqld.service: Control process exited, code=exited status=1
Apr 08 23:22:55 primary systemd[1]: mysqld.service: Failed with result ‘exit-code‘.
Apr 08 23:22:55 primary systemd[1]: Failed to start LSB: start and stop MySQL.
##################################################
截取错误日志/var/log/mysqld.log
##################################################
2021-04-09T06:38:24.889010Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-04-09T06:38:24.889074Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2021-04-09T06:38:24.889090Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.23-log) starting as process 35083 ...
mysqld: File ‘/usr/local/mysql/bin-log/master-bin.index‘ not found (Errcode: 21 - Is a directory)
2021-04-09T06:38:24.895144Z 0 [ERROR] Aborting
2021-04-09T06:38:24.895151Z 0 [Note] Binlog end
2021-04-09T06:38:24.895251Z 0 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
##################################################
日志说未找到/usr/local/mysql/bin-log/master-bin.index文件
清空对应路径下文件master-bin.index后恢复
mv master-bin.index master-bin.index.bak
再次重启后成功
具体什么原因最好的办法是先查看下错误日志:
1、可能是/usr/local/mysql/data/mysql.pid文件没有写的权限
解决方法 :给予权限,执行 “chown -R mysql:mysql /var/data” “chmod -R 755 /usr/local/mysql/data” 然后重新启动mysqld!
2、可能进程里已经存在mysql进程
解决方法:用命令“ps -ef|grep mysqld”查看是否有mysqld进程,如果有使用“kill -9 进程号”杀死,然后重新启动mysqld!
3、可能是第二次在机器上安装mysql,有残余数据影响了服务的启动。
解决方法:去mysql的数据目录/data看看,如果存在mysql-bin.index,就赶快把它删除掉吧,它就是罪魁祸首了。本人就是使用第三条方法解决的 !
4、mysql在启动时没有指定配置文件时会使用/etc/my.cnf配置文件,请打开这个文件查看在[mysqld]节下有没有指定数据目录(datadir)。
解决方法:请在[mysqld]下设置这一行:datadir = /usr/local/mysql/data
5、skip-federated字段问题
解决方法:检查一下/etc/my.cnf文件中有没有没被注释掉的skip-federated字段,如果有就立即注释掉吧。
6、错误日志目录不存在
解决方法:使用“chown” “chmod”命令赋予mysql所有者及权限
7、selinux惹的祸,如果是centos系统,默认会开启selinux
解决方法:关闭它,打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX=disabled后存盘退出重启机器试试。
以上摘抄https://blog.csdn.net/miss1181248983/article/details/82426283
如有用户权限启动问题,可尝试如下修改
cp /etc/init.d/mysqld mysqld.bak
修改mysql启动文件start模块
添加--user=root到mysqld_safe
$bindir/mysqld_safe --user=root --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null &
标签:sys bin success exp 二次 tps 安装 文件丢失 safe
原文地址:https://www.cnblogs.com/hongliang-dba/p/14637434.html