启动服务失败,查看错误日志
#vim /var/log/mysql.log
在启动mysql服务时报错:
2024-12-07T03:05:12.316176Z 0 [ERROR] [MY-010183] [Server] Failed to create file(file: '/data/mysql/data/auto.cnf', errno 13)
2024-12-07T03:05:12.316191Z 0 [ERROR] [MY-010076] [Server] Initialization of the server's UUID failed because it could not be read from the auto.cnf file. If this is a new server, the initialization failed because it was not possible to generate a new UUID.
2024-12-07T03:05:12.316249Z 0 [ERROR] [MY-010119] [Server] Aborting
2024-12-07T03:05:12.316404Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.28) MySQL Community Server - GPL.
2024-12-07T03:07:02.641634Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.28) starting as process 9433
2024-12-07T03:07:02.646244Z 0 [Warning] [MY-010075] [Server] 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: 54e127bd-b448-11ef-b03e-fa163e85d8bb.
原因:这个错误表明MySQL服务在尝试访问其配置文件auto.cnf时遇到了权限问题。文件/data/mysql/data/auto.cnf不存在,同时提示操作系统的错误编号13,这通常表示“权限被拒绝”(Permission denied)。
解决办法:
# chown -R mysql:mysql /data/mysql/data/