Score:2

How to stop unstoppable mysql-server package on Ubuntu 20.04

ua flag

So I purged and then tried to install mysql-server package on Ubuntu 20.04, it doesn't let for some configure problem. I found out that it doesn't even stopped and it seems that it automatically runs itself up again, I can't stop it no matter what

gediminas@ubuntu-g:~$ sudo ps aux | grep mysql
systemd+    9177  5.5  2.2 2123136 364052 ?      Ssl  21:21   0:00 mysqld
gedimin+    9354  0.0  0.0  20200  2548 pts/0    S+   21:21   0:00 grep --color=auto mysql
gediminas@ubuntu-g:~$ sudo pkill mysql
gediminas@ubuntu-g:~$ sudo ps aux | grep mysql
gedimin+    9365  0.0  0.0  20200  2652 pts/0    S+   21:21   0:00 grep --color=auto mysql
gediminas@ubuntu-g:~$ sudo ps aux | grep mysql
systemd+    9432 26.0  1.9 722716 317524 ?       Ssl  21:21   0:00 mysqld
gedimin+    9553  0.0  0.0  20200   664 pts/0    S+   21:22   0:00 grep --color=auto mysql
gediminas@ubuntu-g:~$ sudo ps aux | grep mysql
systemd+    9432 41.0  2.2 1926528 363848 ?      Ssl  21:21   0:00 mysqld
gedimin+    9585  0.0  0.0  20200   664 pts/0    S+   21:22   0:00 grep --color=auto mysql
gediminas@ubuntu-g:~$ sudo ps aux | grep mysql
systemd+    9432 41.0  2.2 1926528 363848 ?      Ssl  21:21   0:00 mysqld
gedimin+    9588  0.0  0.0  20200   660 pts/0    S+   21:22   0:00 grep --color=auto mysql

systemctl status mysql shows :

● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; disabled; vendor preset: enabled)
     Active: activating (start) since Sat 2021-07-24 21:43:57 EEST; 1s ago
    Process: 21011 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 21019 (mysqld)
     Status: "Server startup in progress"
      Error: 98 (Address already in use)
      Tasks: 17 (limit: 19032)
     Memory: 331.6M
     CGroup: /system.slice/mysql.service
             └─21019 /usr/sbin/mysqld

liep. 24 21:43:57 ubuntu-g systemd[1]: Starting MySQL Community Server...

and after spamming it a bit it shows one failure

● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; disabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Sat 2021-07-24 21:44:35 EEST; 270ms ago
    Process: 21763 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
    Process: 21771 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
   Main PID: 21771 (code=exited, status=1/FAILURE)
     Status: "Server startup in progress"
      Error: 98 (Address already in use)

liep. 24 21:44:36 ubuntu-g systemd[1]: mysql.service: Scheduled restart job, restart counter is at 139.
liep. 24 21:44:36 ubuntu-g systemd[1]: Stopped MySQL Community Server.
liep. 24 21:44:36 ubuntu-g systemd[1]: Starting MySQL Community Server...

When I purge all mysql packages and try to install mysql-server I get this error

update-alternatives: using /var/lib/mecab/dic/ipadic-utf8 to provide /var/lib/mecab/dic/debian (mecab-dictionary) in auto mode
Setting up mysql-server-8.0 (8.0.25-0ubuntu0.20.04.1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 29427
dpkg: error processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script 

subprocess returned error exit status 1
    No apport report written because the error message indicates its a followup error from a previous failure.


dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-8.0; however:
  Package mysql-server-8.0 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Processing triggers for systemd (245.4-4ubuntu3.11) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Errors were encountered while processing:
 mysql-server-8.0
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

When I install mysql-server and run dpkg -l 'mysql*' I get

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                  Version                 Architecture Description
+++-=====================-=======================-============-=================================================>
un  mysql-client-5.7      <none>                  <none>       (no description available)
ii  mysql-client-8.0      8.0.25-0ubuntu0.20.04.1 amd64        MySQL database client binaries
un  mysql-client-core-5.7 <none>                  <none>       (no description available)
ii  mysql-client-core-8.0 8.0.25-0ubuntu0.20.04.1 amd64        MySQL database core client binaries
ii  mysql-common          5.8+1.0.5ubuntu2        all          MySQL database common files, e.g. /etc/mysql/my.c>
un  mysql-common-5.6      <none>                  <none>       (no description available)
iU  mysql-server          8.0.25-0ubuntu0.20.04.1 all          MySQL database server (metapackage depending on t>
un  mysql-server-5.5      <none>                  <none>       (no description available)
un  mysql-server-5.7      <none>                  <none>       (no description available)
iF  mysql-server-8.0      8.0.25-0ubuntu0.20.04.1 amd64        MySQL database server binaries and system databas>
un  mysql-server-core-5.7 <none>                  <none>       (no description available)
ii  mysql-server-core-8.0 8.0.25-0ubuntu0.20.04.1 amd64        MySQL database server binaries

mysql-server:
  Installed: 8.0.25-0ubuntu0.20.04.1
  Candidate: 8.0.25-0ubuntu0.20.04.1
  Version table:
 *** 8.0.25-0ubuntu0.20.04.1 500
        500 http://lt.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://lt.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages
        100 /var/lib/dpkg/status
     8.0.19-0ubuntu5 500
        500 http://lt.archive.ubuntu.com/ubuntu focal/main amd64 Packages
        500 http://lt.archive.ubuntu.com/ubuntu focal/main i386 Packages

Solution

It happened that mysql-server package was just broken so here is how to fix it :

  1. Restart computer and boot while holding shift, it must bring you into GNU BRUB menu
  2. Select Advanced options for Ubuntu
  3. Select Ubuntu, with Linux X.XX.X-XX (recovery mode)
  4. And then in Recovery Menu just select Repair broken packages
anx avatar
fr flag
anx
Directly killing processes managed by any sort of service manager has been bad practice for about the entirety of MySQLs weird history. In the case of `Ubuntu 20.04`, you probably want to start reading about *systemD* and specifically its utility `systemctl`.
Michael Hampton avatar
cz flag
I think you may have somehow installed more than one distinct version of MySQL. Check with something like `dpkg -l 'mysql*'`
digijay avatar
mx flag
Did you try `sudo systemctl stop mysql && sudo dpkg-reconfigure mysql-server-8.0`? Because the error message says that mysql 8.0 is not configured yet.
Gediminas avatar
ua flag
@digijay I get `/usr/sbin/dpkg-reconfigure: mysql-server-8.0 is broken or not fully installed`
digijay avatar
mx flag
Please add the output of `sudo apt-cache policy mysql-server` [to your question](https://serverfault.com/posts/1070522/edit)
digijay avatar
mx flag
Hmm, that's strange, and `sudo apt-get install mysql-server-8.0 --reinstall` also doesn't work?
Gediminas avatar
ua flag
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/127877/discussion-between-gediminas-and-digijay).
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.