服务器上的MySQL启动失败:Starting MySQL...The server quit without updating PID file

Posted 夜中听雪

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了服务器上的MySQL启动失败:Starting MySQL...The server quit without updating PID file相关的知识,希望对你有一定的参考价值。

环境

阿里云服务器、CentOS 7.9.2009。通过宝塔面板安装的mysql 8.0.23。

重现下我是怎么遇到该问题的

问题:mysql无法启动。

[root@wu1 ~]# service mysqld status	# mysql本来是启动的
MySQL running (31824)                                      [  OK  ]
[root@wu1 ~]# service mysqld start	# 我查tomcat一个错误日志的解决方法时,说出现这个错是因为mysql没启动,我就输入该命令启动mysql
Starting MySQL...The server quit without updating PID file [FAILED]rver/data/wu1.pid).
[root@wu1 ~]# service mysqld status	# 结果mysql关闭了。
[root@wu1 ~]# service mysqld start	# 启动不起来
Starting MySQL...The server quit without updating PID file [FAILED]rver/data/wu1.pid).
MySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED]

解决思路

查看mysql日志:

2021-05-17T02:14:14.833396Z 0 [Warning] [MY-000081] [Server] option 'max_allowed_packet': unsigned value 107374182400 adjusted to 1073741824.
2021-05-17T02:14:14.833476Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2021-05-17T02:14:14.833598Z 0 [System] [MY-010116] [Server] /www/server/mysql/bin/mysqld (mysqld 8.0.23) starting as process 2856
2021-05-17T02:14:14.851898Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-05-17T02:14:15.125617Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-05-17T02:14:15.235190Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/tmp/mysqlx.sock' failed, `bind()` on UNIX socket failed with error: Address already in use (98).  Do you already have another mysqld server running with Mysqlx ?'
2021-05-17T02:14:15.235474Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060
2021-05-17T02:14:15.345812Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-05-17T02:14:15.346119Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-05-17T02:14:15.350838Z 0 [ERROR] [MY-010270] [Server] Can't start server : Bind on unix socket: Address already in use
2021-05-17T02:14:15.351135Z 0 [ERROR] [MY-010258] [Server] Do you already have another mysqld server running on socket: /tmp/mysql.sock ?
2021-05-17T02:14:15.351619Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-05-17T02:14:16.771300Z 0 [System] [MY-010910] [Server] /www/server/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.23)  Source distribution.

查看[ERROR]的几句,里面说:Bind on unix socket: Address already in use

但此时,3306端口没有被占用,也没有mysql进程,如下。

[root@wu1 ~]# netstat -an|grep 3306	
[root@wu1 ~]# ps -ef | grep mysql
root     22700 18383  0 09:38 pts/4    00:00:00 grep --color=auto mysql

解决方法

解决原因:日志中有提到:Do you already have another mysqld server running on socket: /tmp/mysql.sock ?Plugin mysqlx reported: 'Setup of socket: '/tmp/mysqlx.sock' failed, bind() on UNIX socket failed with error: Address already in use (98). Do you already have another mysqld server running with Mysqlx ?'

解决方法:删除/tmp目录下的下图四个文件,即:mysql.sock.lock、mysql.sock、mysqlx.sock.lock、mysqlx.sock。
在这里插入图片描述

启动成功

再次启动mysql,启动成功。

[root@wu1 ~]# service mysqld start
Starting MySQL..                                           [  OK  ]
[root@wu1 ~]# ps -ef | grep mysql
root      3186     1  0 10:16 pts/4    00:00:00 /bin/sh /www/server/mysql/bin/mysqld_safe --datadir=/www/server/data --pid-file=/www/server/data/wu1.pid
mysql     3802  3186  1 10:16 pts/4    00:00:00 /www/server/mysql/bin/mysqld --basedir=/www/server/mysql --datadir=/www/server/data --plugin-dir=/www/server/mysql/lib/plugin --user=mysql --log-error=wu1.err --open-files-limit=65535 --pid-file=/www/server/data/wu1.pid --socket=/tmp/mysql.sock --port=3306
root      3976 18383  0 10:17 pts/4    00:00:00 grep --color=auto mysql

以上是关于服务器上的MySQL启动失败:Starting MySQL...The server quit without updating PID file的主要内容,如果未能解决你的问题,请参考以下文章

Starting MySQL....The server quit without updating PID file[失败]/lib/mysql/ip12189.pid). 错误一例

MySQL启动出现Starting MySQL.The server quit without up

Starting named:[FAILED] named启动失败

ubuntu上的服务mysql启动失败[关闭]

xampp上的mysql服务器不起作用

Centos 6.7 系统启动失败