环境介绍

Linux:腾讯云服务器:CentOS 7.6 64bit
mysql:Server version: 8.0.26 MySQL Community Server

安装参考贴

[菜鸟驿站](https://www.runoob.com/mysql/mysql-install.html)

遇到的问题

在启动 MySQL:systemctl start mysqld 后系统提示服务启动失败。

Starting mysqld (via systemctl):  Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
                                                           [FAILED]

解决问题

定位问题

1、通过查看mysql的日志,发现是一个文件权限的问题。
查看日志

2021-09-29T08:31:42.480432Z 0 [ERROR] [MY-010076] [Server] Initialization of the server's UUID failed because it read from the auto.cnf file. If this is a new server, the initialization failed because it was not possible to w UUID.
2021-09-29T08:31:42.480491Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-09-29T08:31:42.481033Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.26) ity Server - GPL.
2021-09-29T08:37:50.902988Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.26) starting as process
2021-09-29T08:37:50.910660Z 0 [Warning] [MY-010075] [Server] No existing UUID has been found, so we assume that irst time that this server has been started. Generating a new UUID: 881f32f5-2100-11ec-bf9f-525400fdd633.
mysqld: File '/var/lib/mysql/auto.cnf' not found (OS errno 13 - Permission denied) (权限不足 chmod 777 auto.cnf之后即可)
2021-09-29T08:37:50.910770Z 0 [ERROR] [MY-010183] [Server] Failed to create file(file: '/var/lib/mysql/auto.cnf'
2021-09-29T08:37:50.910805Z 0 [ERROR] [MY-010076] [Server] Initialization of the server's UUID failed because it read from the auto.cnf file. If this is a new server, the initialization failed because it was not possible to w UUID.
2021-09-29T08:37:50.910892Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-09-29T08:37:50.911657Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.26) ity Server - GPL.

2、仔细查看这段输出日志的信息,主要提示的是问卷找不到或者权限不足。

mysqld: File '/var/lib/mysql/auto.cnf' not found (OS errno 13 - Permission denied) (权限不足 chmod 777 auto.cnf之后即可)

3、查看该路径下这个文件的权限
原始权限

解决步骤

首先改变这个文件的权限。(我这里直接给最高的权限了)
修改权限
修改后权限
此时重新启动mysql service 成功。
启动成功

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐