MySQL从5.7升级到8.0失败,步骤EXEC失败,生成mysql-systemd-start

时间:2019-05-08 05:46:38

标签: mysql ubuntu-16.04

我尝试使用以下命令将MySQL 5.7.21更新为MySQL 8.0

wget https://repo.mysql.com//mysql-apt-config_0.8.10-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.10-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server

但是安装步骤会导致错误

systemd[1]: Starting MySQL Community Server...
systemd[15390]: mysql.service: Failed at step EXEC spawning /usr/share/mysql/mysql-systemd-start: No such file or directory
systemd[1]: mysql.service: Control process exited, code=exited status=203
systemd[1]: Failed to start MySQL Community Server.
systemd[1]: mysql.service: Unit entered failed state.
systemd[1]: mysql.service: Failed with result 'exit-code'.
systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
systemd[1]: Stopped MySQL Community Server.
systemd[1]: Starting MySQL Community Server...
systemd[15399]: mysql.service: Failed at step EXEC spawning /usr/share/mysql/mysql-systemd-start: No such file or directory
systemd[1]: mysql.service: Control process exited, code=exited status=203
systemd[1]: Failed to start MySQL Community Server.
systemd[1]: mysql.service: Unit entered failed state.
systemd[1]: mysql.service: Failed with result 'exit-code'.
systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
systemd[1]: Stopped MySQL Community Server.
systemd[1]: Starting MySQL Community Server...
systemd[15424]: mysql.service: Failed at step EXEC spawning /usr/share/mysql/mysql-systemd-start: No such file or directory
systemd[1]: mysql.service: Control process exited, code=exited status=203
systemd[1]: Failed to start MySQL Community Server.
systemd[1]: mysql.service: Unit entered failed state.
systemd[1]: mysql.service: Failed with result 'exit-code'.
systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
systemd[1]: Stopped MySQL Community Server.

我真的不确定在哪里可以找到此文件mysql-systemd-start,因为当我查看/usr/share/mysql/时该目录不存在!

感谢您的帮助。

2 个答案:

答案 0 :(得分:0)

修复两个步骤:

  1. vim /etc/systemd/system/mysql.service并删除ExecStartPre=/usr/share/mysql/mysql-systemd-start preExecStartPost=/usr/share/mysql/mysql-systemd-start post

  2. 重启

答案 1 :(得分:0)

虽然@РоманВ的答案在技术上是正确的,但正确的方法是使用systemd的功能来覆盖单位文件,而不是修改系统文件,因为升级软件包后,系统文件很可能会被覆盖。 / p>

  1. 使用systemctl edit mysql.service
  2. 将生成空白文本编辑器
  3. 添加以下内容:
[Service]
ExecStartPre=
ExecStartPost=
  1. 保存并退出

您可以使用systemctl cat mysql.service来验证编辑:

编辑前:

# systemctl cat mysql.service
# /etc/systemd/system/mysql.service
# MySQL systemd service file

[Unit]
Description=MySQL Community Server
After=network.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql
PermissionsStartOnly=true
ExecStartPre=/usr/share/mysql/mysql-systemd-start pre
ExecStart=/usr/sbin/mysqld
ExecStartPost=/usr/share/mysql/mysql-systemd-start post
TimeoutSec=600
Restart=on-failure
RuntimeDirectory=mysqld
RuntimeDirectoryMode=755

LimitNOFILE=infinity
LimitMEMLOCK=infinity

修改后(覆盖):

# systemctl cat mysql.service
# /etc/systemd/system/mysql.service
# MySQL systemd service file

[Unit]
Description=MySQL Community Server
After=network.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql
PermissionsStartOnly=true
ExecStartPre=/usr/share/mysql/mysql-systemd-start pre
ExecStart=/usr/sbin/mysqld
ExecStartPost=/usr/share/mysql/mysql-systemd-start post
TimeoutSec=600
Restart=on-failure
RuntimeDirectory=mysqld
RuntimeDirectoryMode=755

LimitNOFILE=infinity
LimitMEMLOCK=infinity


# /etc/systemd/system/mysql.service.d/override.conf
[Service]
ExecStartPre=
ExecStartPost=

请注意,override.conf和我添加的内容都存在。

此后,您可以放心dpkg --reconfigure -a,以完成升级过程。