当前位置: 首页 > 知识库问答 >
问题:

Ubuntu 20.04-停止了MySQL。现在它无法启动(错误13,权限被拒绝)

李联
2023-03-14

在Ubuntu 20.04上运行DigitalOcean LAMP Stack (1GB VPS)时,我在上传媒体文件时在Wordpress中得到间歇性的“错误建立数据库连接”错误。这将引发以下Apache错误:

WordPress数据库错误MySQL服务器已经消失了查询...

出现此问题时,MySQL日志反复打印以下内容,此后就没有其他内容了:

    2020-12-19T12:14:43.708558Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
    2020-12-19T12:14:43.992793Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.22-0ubuntu0.20.04.3'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu).
    2020-12-19T12:14:59.498001Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.22-0ubuntu0.20.04.3) starting as process 190645
    2020-12-19T12:14:59.512933Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
    2020-12-19T12:15:00.093514Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
    2020-12-19T12:15:00.448326Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '127.0.0.1' port: 33060, socket: /var/run/mysqld/mysqlx.sock
    2020-12-19T12:15:00.524531Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...
    2020-12-19T12:15:00.543848Z 0 [System] [MY-010232] [Server] XA crash recovery finished.
    2020-12-19T12:15:00.652394Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.

我尝试了这个修复:WordPress数据库错误MySQL服务器已经离开查询

网站仍然显示错误,所以我想我应该重新启动MySQL,但它不会重新启动。

使用< code>sudo服务MySQL start,我得到

mysql.服务的作业失败,因为控制进程退出并显示错误代码。有关详细信息,请参阅“系统代码状态 mysql.service”和“日志引用 -xe”。

运行第一个命令:

● mysql.service - MySQL Community Server
 Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
 Active: failed (Result: exit-code) since Sat 2020-12-19 12:45:50 UTC; 1min 3s ago
Process: 192068 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 192076 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Main PID: 192076 (code=exited, status=1/FAILURE)
 Status: "Server startup in progress"
  Error: 13 (Permission denied)

运行第二个命令

 Hint: You are currently not seeing messages from other users and the system.
  Users in groups 'adm', 'systemd-journal' can see all messages.
  Pass -q to turn off this notice.
 -- Defined-By: systems
 -- Support: http://www.ubuntu.com/support
 --
 -- A start job for unit UNIT has finished successfully.
 --
 -- The job identifier is 8.
 Dec 19 12:13:48 server systemd[189372]: Listening on REST API socket for snapd user session agent.
 -- Subject: A start job for unit UNIT has finished successfully
 -- Defined-By: systems
 -- Support: http://www.ubuntu.com/support
 --
 -- A start job for unit UNIT has finished successfully.
 --
 -- The job identifier is 11.
 Dec 19 12:13:48 server systemd[189372]: Listening on D-Bus User Message Bus Socket.
 -- Subject: A start job for unit UNIT has finished successfully
 -- Defined-By: systems
 -- Support: http://www.ubuntu.com/support
 --
 -- A start job for unit UNIT has finished successfully.
 --
 -- The job identifier is 9.
 Dec 19 12:13:48 server systemd[189372]: Reached target Sockets.
 -- Subject: A start job for unit UNIT has finished successfully
 -- Defined-By: systems
 -- Support: http://www.ubuntu.com/support
 --
 -- A start job for unit UNIT has finished successfully.
 --
 -- The job identifier is 5.
 Dec 19 12:13:48 server systemd[189372]: Reached target Basic System.
 -- Subject: A start job for unit UNIT has finished successfully
 -- Defined-By: systems
 -- Support: http://www.ubuntu.com/support
 --
 -- A start job for unit UNIT has finished successfully.
 --
 -- The job identifier is 2.
 Dec 19 12:13:48 server systemd[189372]: Reached target Main User Target.
 -- Subject: A start job for unit UNIT has finished successfully
 -- Defined-By: systems
 -- Support: http://www.ubuntu.com/support
 --
 -- A start job for unit UNIT has finished successfully.
 --
 -- The job identifier is 1.
 Dec 19 12:13:48 server systemd[189372]: Startup finished in 168ms.
 -- Subject: User manager start-up is now complete
 -- Defined-By: systems
 -- Support: http://www.ubuntu.com/support
 --
 -- The user manager instance for user 1000 has been started. All services queued
 -- for starting have been started. Note that other services might still be starting
 -- up or be started at any later time.
 --
 -- Startup of the manager took 168965 microseconds.
 Dec 19 12:15:07 server sudo[190726]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
 Dec 19 12:15:09 server sudo[190726]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
 Dec 19 12:30:17 server sudo[191518]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
 Dec 19 12:30:19 server sudo[191518]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
 Dec 19 12:32:25 server sudo[191686]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
 Dec 19 12:32:27 server sudo[191686]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory

第一个错误导致了这个:https://askubuntu.com/questions/1228827/mysql-error-13-permission-denied

然而MySQL已经拥有了/var/lib/mysql。/usr/sbin/mysqld的所有者是root。这与MySQL运行良好的另一台服务器上的情况相同。我真的应该改变这一点吗?

共有3个答案

夏侯腾
2023-03-14

如果您手动删除数据库日志文件,也可能会发生这种情况。检查/var/log/mysql/error.log,以及问题是否与最后一个数据库日志文件有关。在这种情况下,清除文件/var/lib/mysql/binlog.index的内容,然后重新启动mysql帮助了我。

胡泓
2023-03-14

简单运行update命令< br > apt-get update < br > apt-get upgrade < br >它自动更新mysql必需的权限。< br >它解决了我的问题

陶飞英
2023-03-14

问题是我给了我的用户 /var/log/mysql的所有权来读取文件。sudo chown mysql: mysql-R /var/log/mysql允许我启动mysql。

 类似资料:
  • 我在django admin(127.0.0.1:8000/admin)中尝试为用户添加个人资料照片时收到此错误消息 有人能帮我找出原因吗? OSError at /admin/role/role/6/[Errno 13]权限被拒绝:'/User'请求方法: POST请求URL:http://127.0.0.1:8000/admin/role/role/6/Django版本: 1.8.2异常类型:

  • 问题内容: 问题 :无法停止泊坞窗容器,每当我尝试停止容器时,都会收到以下错误消息, 操作系统版本/内部版本: Ubuntu 16.04 | Docker版本17.09.0-ce,构建afdb6d4 | Docker Compose版本1.17.1,内部版本6d101fb 重现步骤: 使用Dockerfile和docker-compose.yml创建了Rails项目。docker-compose.

  • 问题内容: 我正在尝试执行以下代码: 我收到以下错误: 我检查了我是否具有必要的权限,并通过终端找到了该权限: 关于如何使它工作的任何建议? 问题答案: 您需要更改xyz.exe的权限

  • 问题内容: 我正在尝试通过管理页面上传图片,但一直在说: 上载时动态创建文件夹 。 在Traceback中,我发现此命令期间发生错误: 在/usr/lib64/python2.6/os.py第157行中,同时调用 意思是,它不能创建任何文件夹,因为它没有执行此操作的权限 我在服务器中将OpenSuse作为OS。在httpd.conf中,我有这个: 我需要chmod或chown吗? 问题答案: 您需

  • 问题内容: 我运行 npm install lodash, 但它抛出 错误:EACCES:权限被拒绝 错误。我知道这是权限问题,但据我所知,本地安装节点模块不需要sudo权限。如果我使用sudo运行它,它将安装在〜/ node_modules文件夹中。 drwxrwxr-x 是现有文件夹的文件许可权。我不知道可能出了什么问题。 下面是错误消息。 问题答案: 使用 npm init 创建 packa

  • 我运行npm install lodash,但它抛出错误:EACCES:权限被拒绝错误。我知道这是权限问题,但据我所知,在本地安装节点模块不需要sudo权限。如果我用sudo运行它,它会安装在~/node\u modules文件夹中。drwxrwxr-x是现有文件夹的文件权限。我不知道可能出了什么问题。 下面是错误消息。