更新至 Ubuntu 22.04.2 后无法启动 MySQL 社区服务器

更新至 Ubuntu 22.04.2 后无法启动 MySQL 社区服务器

我已将 DigitalOcean 上的 Ubuntu 服务器更新到版本 22.04.2。现在我无法登录 phpMyAdmin(我的 Flask 网站也无法连接到 MYSQL)。尝试登录 phpMyAdmin 时出现以下 4 条错误消息。

  • 无法登录 MySQL 服务器
  • mysqli::real_connect():(HY000/2002):连接被拒绝
  • 按照您的配置定义的控制用户连接失败
  • mysqli::real_connect():(HY000/2002):连接被拒绝

我已经尝试注释掉

query_cache_limit =

query_cache_size =

来自 /etc/mysql/my.cnf 文件。但它也不起作用。

systemctl status mysql.service 

显示以下内容。

× mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2023-03-07 04:55:10 UTC; 52min ago
    Process: 1830 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
        CPU: 30ms

Mar 07 04:55:09 mail systemd[1]: mysql.service: Control process exited, code=exited, status=1/FAILURE
Mar 07 04:55:09 mail systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 07 04:55:09 mail systemd[1]: Failed to start MySQL Community Server.
Mar 07 04:55:10 mail systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Mar 07 04:55:10 mail systemd[1]: Stopped MySQL Community Server.
Mar 07 04:55:10 mail systemd[1]: mysql.service: Start request repeated too quickly.
Mar 07 04:55:10 mail systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 07 04:55:10 mail systemd[1]: Failed to start MySQL Community Server.

以及journalctl -xeu mysql.service

An ExecStartPre= process belonging to unit mysql.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 1.
Mar 07 04:55:09 mail systemd[1]: mysql.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit mysql.service has entered the 'failed' state with result 'exit-code'.
Mar 07 04:55:09 mail systemd[1]: Failed to start MySQL Community Server.
░░ Subject: A start job for unit mysql.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit mysql.service has finished with a failure.
░░ 
░░ The job identifier is 1559 and the job result is failed.
Mar 07 04:55:10 mail 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.
Mar 07 04:55:10 mail systemd[1]: Stopped MySQL Community Server.
░░ Subject: A stop job for unit mysql.service has finished
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A stop job for unit mysql.service has finished.
░░ 
░░ The job identifier is 1642 and the job result is done.
Mar 07 04:55:10 mail systemd[1]: mysql.service: Start request repeated too quickly.
Mar 07 04:55:10 mail systemd[1]: mysql.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit mysql.service has entered the 'failed' state with result 'exit-code'.
Mar 07 04:55:10 mail systemd[1]: Failed to start MySQL Community Server.
░░ Subject: A start job for unit mysql.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit mysql.service has finished with a failure.
░░ 
░░ The job identifier is 1642 and the job result is failed.

如何解决这个问题以及从哪里开始?

答案1

您可以尝试解决此问题,可以采取几个步骤。

sudo systemctl status mysql.service首先,您可以使用终端中的命令“ ”检查 MySQL 是否正在运行。如果 MySQL 没有运行,您可以检查“ /var/log/mysql/error.log”处的错误日志,查找任何可能有助于诊断问题的错误消息。使用“ sudo systemctl restart mysql.service”重新启动 MySQL 是另一种选择。

您还可以检查“ ”上的 MySQL 配置文件/etc/mysql/my.cnf是否存在任何配置问题,并确保防火墙设置没有阻止流向 MySQL 的流量。

sudo mysql -u root -p最后,在终端中使用“”检查 MySQL 用户帐户和权限可以帮助解决问题。如果这些步骤都不起作用,可能需要向 MySQL 专家或 DigitalOcean 支持团队寻求进一步帮助。

如果有帮助的话请告诉我!

相关内容