在Ubuntu 20.04上运行DigitalOcean LAMP Stack(1GB VPS),上传媒体文件时,我在WordPress中收到间歇性的“Error establshing a database connection”错误。
第一个月
发生此问题时,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 database error MySQL server has gone away for query
网站仍然显示错误,所以我想我应该重新启动MySQL,但它不会重新启动。
对于sudo service MySQL start
,我得到Job for mysql.service failed because the control process exited with error code. 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 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正常工作的另一个服务器上的所有者相同。我真的应该更改它吗?
5条答案
按热度按时间jobtbby31#
问题是我已经给了我的用户/var/log/mysql的所有权来读取文件。
sudo chown mysql:mysql -R /var/log/mysql
允许我启动mysql。mhd8tkvw2#
简单运行更新命令
**apt-get更新
apt-获取升级**
它自动更新权限必要的mysql。
它解决了我的问题
mf98qq943#
如果你手动删除
binlog
文件,也可能会发生这种情况。检查/var/log/mysql/error.log
,如果问题与最后一个binlog文件有关。在这种情况下,清除文件/var/lib/mysql/binlog.index
的内容,然后重新启动mysql帮助了我。w8ntj3qf4#
有相同的问题
system status mysql Main PID: 178577 (code=exited, status=1/FAILURE) Status: "Server startup in progress" Error: 13 (Permission denied)
解决方案chown mysql:mysql -R /var/lib/mysql/ /var/log/mysql/
启动正常9jyewag05#
我也遇到了同样的问题,我把mysql数据目录从
/var/lib/mysql
移到/media/anand/databank/mysql
,我给了所有用户/组所有的读写权限,但是mysql服务器无法用Error: 13 (Permission denied)
重新启动,反复阅读这个线程和其他线程后,我发现文件夹anand
没有给其他人访问权限(包括用户mysql)。因此,即使用户(在我的情况下mysql)有完全访问mysql
文件夹,但该用户将无法到达mysql
文件夹,直到该用户获得访问anand
文件夹的权限.有一次,我授予只读权限mysql用户对foledranand
,mysql服务器已启动,没有错误。简而言之,如果您授予某个用户对某个文件夹的权限。请检查该用户是否至少对所有父文件夹具有只读/访问文件权限