MySQL 社区服务器未在 ubuntu 18.04 中启动

MySQL 社区服务器未在 ubuntu 18.04 中启动

每当我运行时,systemctl status mysql.service都会出现以下输出:

    ● mysql.service - MySQL Community Server
    Loaded: loaded (/lib/systemd/system/mysql.service; disabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Wed 2020-10-07 22:36:27 UTC; 17s ago
    Process: 7996 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)

    Oct 07 22:36:27 ns5002486 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
    Oct 07 22:36:27 ns5002486 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
    Oct 07 22:36:27 ns5002486 systemd[1]: Stopped MySQL Community Server.
    Oct 07 22:36:27 ns5002486 systemd[1]: mysql.service: Start request repeated too quickly.
    Oct 07 22:36:27 ns5002486 systemd[1]: mysql.service: Failed with result 'exit-code'.
    Oct 07 22:36:27 ns5002486 systemd[1]: Failed to start MySQL Community Server.

其结果如下journalctl -xe -u mysql.service

    Oct 07 22:36:27 ns5002486 systemd[1]: mysql.service: Scheduled restart job, rest
    -- 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 res
    -- the configured Restart= setting for the unit.
    Oct 07 22:36:27 ns5002486 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.
    Oct 07 22:36:27 ns5002486 systemd[1]: mysql.service: Start request repeated too
    Oct 07 22:36:27 ns5002486 systemd[1]: mysql.service: Failed with result 'exit-co
    Oct 07 22:36:27 ns5002486 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.
    lines 359-381/381 (END)
    Oct 07 22:36:27 ns5002486 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.
    Oct 07 22:36:27 ns5002486 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.
    Oct 07 22:36:27 ns5002486 systemd[1]: mysql.service: Start request repeated too quickly.
    Oct 07 22:36:27 ns5002486 systemd[1]: mysql.service: Failed with result 'exit-code'.
    Oct 07 22:36:27 ns5002486 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.

systemctl start mysql.service和的结果journalctl -xe

    Job for mysql.service failed because the control process exited with error code.
    See "systemctl status mysql.service" and "journalctl -xe" for details.
    root@ns5002486:~# journalctl -xe
    -- Support: http://www.ubuntu.com/support
    --
    -- Unit mysql.service has begun starting up.
    Oct 11 03:04:30 ns5002486 mysql-systemd-start[32163]: ERROR: Unable to start MySQL server:
    Oct 11 03:04:30 ns5002486 mysql-systemd-start[32163]: mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
    Oct 11 03:04:30 ns5002486 mysql-systemd-start[32163]: 2020-10-11T03:04:30.983966Z 0 [ERROR] Failed to access directory for --secure-file-priv. 
    Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /va
    Oct 11 03:04:30 ns5002486 mysql-systemd-start[32163]: 2020-10-11T03:04:30.986263Z 0 [ERROR] Aborting
    Oct 11 03:04:30 ns5002486 mysql-systemd-start[32163]: Please take a look at https://wiki.debian.org/Teams/MySQL/FAQ for tips on fixing common upgrade issues.
    Oct 11 03:04:30 ns5002486 mysql-systemd-start[32163]: Once the problem is resolved, restart the service.
    Oct 11 03:04:30 ns5002486 systemd[1]: mysql.service: Control process exited, code=exited status=1
    Oct 11 03:04:30 ns5002486 systemd[1]: mysql.service: Failed with result 'exit-code'.
    Oct 11 03:04:30 ns5002486 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.
    Oct 11 03:04:31 ns5002486 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
    Oct 11 03:04:31 ns5002486 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.
    Oct 11 03:04:31 ns5002486 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.
    Oct 11 03:04:31 ns5002486 systemd[1]: mysql.service: Start request repeated too quickly.
    Oct 11 03:04:31 ns5002486 systemd[1]: mysql.service: Failed with result 'exit-code'.
    Oct 11 03:04:31 ns5002486 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.
    Oct 11 03:04:31 ns5002486 sshd[32045]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=222.186.31.83  user=root
    Oct 11 03:04:32 ns5002486 sshd[32134]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=218.92.0.208  user=root
    Oct 11 03:04:34 ns5002486 sshd[32045]: Failed password for root from 222.186.31.83 port 35207 ssh2
    Oct 11 03:04:34 ns5002486 sshd[32134]: Failed password for root from 218.92.0.208 port 42769 ssh2
    Oct 11 03:04:36 ns5002486 sshd[32189]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=218.92.0.208  user=root
    Oct 11 03:04:36 ns5002486 sshd[32045]: Failed password for root from 222.186.31.83 port 35207 ssh2
    Oct 11 03:04:36 ns5002486 sshd[32134]: Failed password for root from 218.92.0.208 port 42769 ssh2
    Oct 11 03:04:38 ns5002486 sshd[32189]: Failed password for root from 218.92.0.208 port 52261 ssh2
    Oct 11 03:04:39 ns5002486 sshd[32045]: Failed password for root from 222.186.31.83 port 35207 ssh2
    Oct 11 03:04:39 ns5002486 sshd[32134]: Failed password for root from 218.92.0.208 port 42769 ssh2
    Oct 11 03:04:39 ns5002486 sshd[32045]: Received disconnect from 222.186.31.83 port 35207:11:  [preauth]
    Oct 11 03:04:39 ns5002486 sshd[32045]: Disconnected from authenticating user root 222.186.31.83 port 35207 [preauth]
    Oct 11 03:04:39 ns5002486 sshd[32045]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=222.186.31.83  user=root
    Oct 11 03:04:39 ns5002486 sshd[32134]: Received disconnect from 218.92.0.208 port 42769:11:  [preauth]
    Oct 11 03:04:39 ns5002486 sshd[32134]: Disconnected from authenticating user root 218.92.0.208 port 42769 [preauth]
    Oct 11 03:04:39 ns5002486 sshd[32134]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=218.92.0.208  user=root
    Oct 11 03:04:39 ns5002486 sshd[32191]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=218.92.0.208  user=root
    Oct 11 03:04:40 ns5002486 sshd[32189]: Failed password for root from 218.92.0.208 port 52261 ssh2
    Oct 11 03:04:41 ns5002486 sshd[32193]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=222.186.31.83  user=root
    lines 1304-1365/1365 (END)

答案1

有一个问题表述得很清楚(我复制了相关部分):

mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
[ERROR] Failed to access directory for --secure-file-priv. 
Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /va
Aborting
Please take a look at https://wiki.debian.org/Teams/MySQL/FAQ for tips on fixing common upgrade issues.

它有众所周知的解决方案,就像我所避开的那个服务器故障

要解决该问题,首先检查您mysqld尝试以何种用户身份运行;在默认的 Debian 安装中,这将是用户“mysql”(我认为对于 Ubuntu 应该相同);要验证这一点,请检查/etc/mysql/my.cnf并查找“user = xxx”行。

一旦您知道 mysqld 尝试以哪个用户身份运行,请检查目录/var/lib/mysql-files是否存在(sudo mkdir /var/lib/mysql-files如果不存在)并且由以该mysqld身份运行的用户拥有(sudo chown mysql /var/lib/mysql-files如果不存在;如果您配置为以其他用户身份运行,请将 chown 命令中的“mysql”替换为正确的用户名)。

然后sudo mysqld重试,您应该会得到一个成功的 mysqld 启动,或者(如果您的设置有其他问题)一个新的不同的错误消息。

相关内容