记录一次mysql启动失败的原因

日志文件error.log显示

2023-09-04T03:41:13.596534Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.28-0kylin0.20.04.3k1) starting as process 1313438
2023-09-04T03:41:13.625439Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-09-04T03:41:14.046678Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-09-04T03:41:14.174364Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/var/run/mysqld/mysqlx.sock' failed, can't create lock file /var/run/mysqld/mysqlx.sock.lock'
2023-09-04T03:41:14.316646Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-09-04T03:41:14.316760Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-09-04T03:41:14.317232Z 0 [ERROR] [MY-010273] [Server] Could not create unix socket lock file /var/run/mysqld/mysqld.sock.lock.
2023-09-04T03:41:14.317280Z 0 [ERROR] [MY-010268] [Server] Unable to setup unix socket lock file.
2023-09-04T03:41:14.317885Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-09-04T03:41:15.708324Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.28-0kylin0.20.04.3k1)  (Ubuntu).

检查发现根本没有/var/run/mysqld/这个路径,更别说这个路径下的文件了,我知道大概率的是权限的问题导致没法创建,于是手动创建lock文件和sock文件,但是还是不行,重启mysql还是失败,日志报错还是同样的信息。

最后解决方式:删掉lock文件和sock文件,执行命令:

sudo chown -R mysql /var/run/mysqld/

将这个路径的读写权限赋予mysql用户

这个解决方案来自:

MySql安装过程中的错误及解决方法记录_could not create unix socket lock file /var/lib/my_1XXXXXXXXXXXXXXXXX1的博客-CSDN博客

你可能感兴趣的:(mysql,数据库)