I had lots and lots of updates to do today on my server, and I think the server was accidentally restarted while it was doing them. Now I can’t use MySQL server anymore, I tried to restart it but it fails, I tried uninstalling it but when I try to install it back it says the server has failed to start (at installation?). I don’t know what to do, I’ve been all day on this and nothing seems to work. Later I’ll update the post with the full errors.
Here’s the info I got:
~$ systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start) since Mon 2024-08-19 18:14:35 CEST; 46s ago
Process: 2363 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 2371 (mysqld)
Status: "Server upgrade in progress"
Tasks: 28 (limit: 4434)
Memory: 485.6M
CPU: 7.522s
CGroup: /system.slice/mysql.service
└─2371 /usr/sbin/mysqld
Aug 19 18:14:35 ubuntu systemd[1]: Starting MySQL Community Server...
~$ journalctl -xeu mysql.service
Aug 19 18:20:48 ubuntu systemd[1]: mysql.service: Scheduled restart job, restart counter is at 7.
░░ 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 19 18:20:48 ubuntu 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 2713 and the job result is done.
Aug 19 18:20:48 ubuntu systemd[1]: mysql.service: Consumed 8.110s CPU time.
░░ Subject: Resources consumed by unit runtime
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit mysql.service completed and consumed the indicated resources.
Aug 19 18:20:48 ubuntu systemd[1]: Starting MySQL Community Server...
░░ Subject: A start job for unit mysql.service has begun execution
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit mysql.service has begun execution.
░░
░░ The job identifier is 2713.
lines 1503-1531/1531 (END)
It says “upgrade in progress”, I don’t understand why rebooting and reinstalling change nothing.
I’ll add something else to maybe reopen this question… (and add more details)
~$ sudo apt remove mysql-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libcgi-fast-perl libcgi-pm-perl libclone-perl libencode-locale-perl libevent-pthreads-2.1-7 libfcgi-bin libfcgi-perl
libfcgi0ldbl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
libio-html-perl liblwp-mediatypes-perl libmecab2 libprotobuf-lite23 libtimedate-perl liburi-perl mecab-ipadic
mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server-8.0
mysql-server-core-8.0
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
mysql-server
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 35.8 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 212025 files and directories currently installed.)
Removing mysql-server (8.0.39-0ubuntu0.22.04.1) ...
Setting up mysql-server-8.0 (8.0.39-0ubuntu0.22.04.1) ...
mysqld will log errors to /var/log/mysql/error.log
2024-08-19T16:40:21.999717Z 0 [ERROR] [MY-010946] [Server] Failed to start mysqld daemon. Check mysqld error log.
Warning: Unable to start the server.
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xeu mysql.service" for details.
invoke-rc.d: initscript mysql, action "restart" failed.
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Mon 2024-08-19 18:41:29 CEST; 21ms ago
Process: 3804 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 3812 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Main PID: 3812 (code=exited, status=1/FAILURE)
Status: "Server shutdown complete"
Error: 2 (No such file or directory)
CPU: 8.152s
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
mysql-server-8.0
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)
5