Sana
Sana

Reputation: 9915

MySQL upgrade from 5.7 to 8.0 fails on Failed at step EXEC spawning mysql-systemd-start

I tried to update MySQL 5.7.21 to MySQL 8.0 using the following commands

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

But the installation step results in an error that says

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.

I am really not sure where I can find this file mysql-systemd-start as when I look in /usr/share/mysql/ the directory doesn't exist!

Thanks for the help.

Upvotes: 1

Views: 3847

Answers (2)

Znuff
Znuff

Reputation: 138

While @Роман В's answer is technically correct, the proper way to do this is to use systemd's ability to override unit files instead of modifying system files which will most likely be overwritten when the package upgrades.

  1. Use systemctl edit mysql.service
  2. A blank text editor will spawn
  3. Add the following:
[Service]
ExecStartPre=
ExecStartPost=
  1. Save & Exit

You can verify the edit with systemctl cat mysql.service:

BEFORE the edit:

# 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

AFTER the edit (override):

# 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=

Notice the presence of the override.conf with the content I added.

After this, you can safely do dpkg --reconfigure -a for the upgrade process to complete.

Upvotes: 1

Роман В
Роман В

Reputation: 37

Two steps to fix:

  1. vim /etc/systemd/system/mysql.service and delete ExecStartPre=/usr/share/mysql/mysql-systemd-start pre and ExecStartPost=/usr/share/mysql/mysql-systemd-start post

  2. reboot

Upvotes: 2

Related Questions