MYSQL 错误:13(权限被拒绝)

MYSQL 错误:13(权限被拒绝)

我收到 *mysql.service 的作业失败,因为控制进程以错误代码退出。

See "systemctl status mysql.service" and "journalctl -xe" for details.* 

当我运行该命令时我得到

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2020-04-20 09:32:04 CDT; 19s ago
  Process: 7287 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
  Process: 7295 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
 Main PID: 7295 (code=exited, status=1/FAILURE)
   Status: "Server startup in progress"
    Error: 13 (Permission denied)

Apr 20 09:32:04 sturtz.ml systemd[1]: mysql.service: Service RestartSec=100ms expired, scheduling restart.
Apr 20 09:32:04 sturtz.ml systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Apr 20 09:32:04 sturtz.ml systemd[1]: Stopped MySQL Community Server.
Apr 20 09:32:04 sturtz.ml systemd[1]: mysql.service: Start request repeated too quickly.
Apr 20 09:32:04 sturtz.ml systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 20 09:32:04 sturtz.ml systemd[1]: Failed to start MySQL Community Server.*

答案1

我运行了以下命令,它在 Ubuntu Server 19.10 上运行良好:

sudo chown -R mysql:mysql /var/lib/mysql/

答案2

您可以登录到该/var/log/mysqld路径并检查mysql错误。

tail -f /var/log/mysqld.log

然后你就可以看到权限错误路径了。示例如下。

"2021-01-13T04:46:06.336009Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-000001 - Can't create/write to file '**/var/run/mysqld/mysqld.pid**' (OS errno 13 - Permission denied)"

现在您可以使用以下命令授予上述路径的访问权限:

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

之后尝试启动mysqld服务。

答案3

binlog如果您手动删除文件,也可能会发生类似的错误。

  • 检查/var/log/mysql/error.log底线,看看原因是否与binlog文件有关。
  • 如果是的,然后清除文件内容/var/lib/mysql/binlog.index然后重新启动 mysql 对我有帮助。

相关内容