我在 18.04 LTS 上使用 MySQL 服务器时遇到问题。我可以运行 MySQL 服务器,并且没有错误/var/log/mysql/error.log
,当我运行 mysqld_safe 时,它只显示此信息
2019-08-14T01:21:17.308139Z mysqld_safe Logging to syslog.
2019-08-14T01:21:17.313454Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2019-08-14T01:21:17.341854Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2019-08-14T01:21:17.588087Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
什么都没发生,我仍然无法通过 systemctl start mysql 运行 mysql 服务。有什么办法可以解决这个问题吗?谢谢
这是 journalctl -xe 的输出
Aug 14 08:25:46 sgp.easycode.id mysqld[16814]: 2019-08-14T01:25:46.211036Z 0 [Note] Binlog end
Aug 14 08:25:46 sgp.easycode.id mysqld[16814]: Initialization of mysqld failed: 0
Aug 14 08:25:46 sgp.easycode.id systemd[1]: mysql.service: Control process exited, code=exited status=1
Aug 14 08:25:46 sgp.easycode.id mysqld[16814]: 2019-08-14T01:25:46.213464Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
Aug 14 08:25:46 sgp.easycode.id systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 14 08:25:46 sgp.easycode.id systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has failed.
--
-- The result is RESULT.
Aug 14 08:25:46 sgp.easycode.id systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Aug 14 08:25:46 sgp.easycode.id systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Automatic restarting of the unit mysql.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Aug 14 08:25:46 sgp.easycode.id systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has finished shutting down.
Aug 14 08:25:46 sgp.easycode.id systemd[1]: mysql.service: Start request repeated too quickly.
Aug 14 08:25:46 sgp.easycode.id systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 14 08:25:46 sgp.easycode.id systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has failed.
--
-- The result is RESULT.
答案1
好的。首先,经过长时间的搜索,我发现 /var/lib/mysql 文件夹的权限设置为 root,而不是 mysql 用户,因此我不在 /var/lib/mysql 上 chmod mysql:mysql。其次是 /var/log/mysql 文件夹和文件设置为 root,我需要将其改回 mysql:adm,所以我照做了,我的 mysql 服务器再次运行没有问题,似乎我在 /root 上 chown root:root .* 搞砸了,导致一切都更改为 root。我很幸运它仍然可以启动。