Unable to unistall mysql package

Asked by chinkleet shukla on 2021-02-07

When I am trying to unisntall "mysql-server 5.7" in my Ubuntu 18.04 machine, getting below error:

sudo apt-get remove --purge mysql-server mysql-client mysql-common -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'mysql-client' is not installed, so not removed
Package 'mysql-server' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  libaio1 mysql-client-core-5.7 mysql-server-core-5.7
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  mysql-client-5.7* mysql-common* mysql-server-5.7
0 upgraded, 0 newly installed, 3 to remove and 358 not upgraded.
2 not fully installed or removed.
After this operation, 31.2 MB disk space will be freed.
debconf: Perl may be unconfigured (Can't locate Debconf/Log.pm in @INC (you may need to install the Debconf::Log module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at (eval 1) line 4.
BEGIN failed--compilation aborted at (eval 1) line 4.
) -- aborting
dpkg: error processing package mysql-server-5.7 (--remove):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting a removal
dpkg: warning: files list file for package 'mysql-server-core-5.7' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'mysql-client-core-5.7' missing; assuming package has no files currently installed
(Reading database ... 245596 files and directories currently installed.)
Removing mysql-client-5.7 (5.7.33-0ubuntu0.18.04.1) ...
Removing mysql-common (5.8+1.0.4) ...
Errors were encountered while processing:
 mysql-server-5.7
E: Sub-process /usr/bin/dpkg returned an error code (1)

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Also tried running below commands:

sudo apt-get autoremove -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

sudo apt --fix-broken install

sudo apt-get autoclean
Reading package lists... Done
Building dependency tree
Reading state information... Done

sudo rm -rf /etc/mysql
sudo find / -iname 'mysql*' -exec rm -rf {} \;

due to this "E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution)." dependencies unable to install any other program into my system.

However when searching for mysql nothing found:

mysql
Command 'mysql' not found, but can be installed with:
sudo apt install mysql-client-core-5.7
sudo apt install mariadb-client-core-10.1

Please guide me on how to remove mysql.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
2021-02-10
Last query:
2021-02-10
Last reply:
2021-02-09
Manfred Hampl (m-hampl) said : #1

What have you done to break your package management system that much?

I assume the two commands
sudo rm -rf /etc/mysql
sudo find / -iname 'mysql*' -exec rm -rf {} \;
have made things worse that they were.

For diagnostic purposes please provide the output that you receive for the commands

uname -a
lsb_release -crid
dpkg -l | grep mysql
sudo dpkg --audit
apt-cache policy mysql-server-5.7 mysql-common

chinkleet shukla (chinks22) said : #2

Hi Manfred,
Thanks for your response.
From the moment i have installed mysql-server, i am getting the same error given below:
(The following packages have unmet dependencies:
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).)

Please find below the output of the required commands:

uname -a
Linux extramarks-Latitude-3400 5.4.0-62-generic #70~18.04.1-Ubuntu SMP Tue Jan 12 17:18:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lsb_release -crid
Distributor ID: Ubuntu
Description: Ubuntu 18.04 LTS
Release: 18.04
Codename: bionic
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dpkg -l | grep mysql
ii mysql-client-core-5.7 5.7.32-0ubuntu0.18.04.1 amd64 MySQL database core client binaries
ic mysql-common 5.8+1.0.4 all MySQL database common files, e.g. /etc/mysql/my.cnf
iHR mysql-server-5.7 5.7.32-0ubuntu0.18.04.1 amd64 (no description available)
ii mysql-server-core-5.7 5.7.33-0ubuntu0.18.04.1 amd64 MySQL database server binaries
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo dpkg --audit
The following packages are in a mess due to serious problems during
installation. They must be reinstalled for them (and any packages
that depend on them) to function properly:
 mysql-server-5.7 (no description available)

The following packages have been triggered, but the trigger processing
has not yet been done. Trigger processing can be requested using
dselect or dpkg --configure --pending (or dpkg --triggers-only):
 man-db on-line manual pager

The following packages are missing the list control file in the
database, they need to be reinstalled:
 mysql-client-core-5.7 MySQL database core client binaries
 mysql-server-5.7 (no description available)
 mysql-server-core-5.7 MySQL database server binaries

The following packages are missing the md5sums control file in the
database, they need to be reinstalled:
 mysql-client-core-5.7 MySQL database core client binaries
 mysql-server-5.7 (no description available)
 mysql-server-core-5.7 MySQL database server binaries

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
apt-cache policy mysql-server-5.7 mysql-common
mysql-server-5.7:
  Installed: 5.7.32-0ubuntu0.18.04.1
  Candidate: 5.7.33-0ubuntu0.18.04.1
  Version table:
     5.7.33-0ubuntu0.18.04.1 500
        500 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
 *** 5.7.32-0ubuntu0.18.04.1 100
        100 /var/lib/dpkg/status
     5.7.21-1ubuntu1 500
        500 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
mysql-common:
  Installed: (none)
  Candidate: 5.8+1.0.4
  Version table:
     5.8+1.0.4 500
        500 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        500 http://in.archive.ubuntu.com/ubuntu bionic/main i386 Packages
        100 /var/lib/dpkg/status

Bernard Stafford (bernard010) said : #3

apt-get autoremove will only remove files which are not in use by any installed package.

Bernard Stafford (bernard010) said : #4

sudo apt-get remove mysql-client-5.7; mysql-common; mysql-server-5
You first check out for the name of the package you want to remove:
dpkg --list
Then remove the given package
sudo apt-get remove package_name
Purge any related code
sudo apt-get purge package_name
Then Autoremove
sudo apt-get autoremove
Finally, do a clean so you check everything is correctly removed
sudo apt-get clean
You would like to check at the packages list whether the one you wanted to remove is not listed anymore, but it is optional.
https://askubuntu.com/questions/151941/how-can-you-completely-remove-a-package

Manfred Hampl (m-hampl) said : #5

Quote:
The following packages are in a mess due to serious problems during
installation. They must be reinstalled for them (and any packages
that depend on them) to function properly:
 mysql-server-5.7 (no description available)

and
The following packages are missing the list control file in the
database, they need to be reinstalled:
 mysql-client-core-5.7 MySQL database core client binaries
 mysql-server-5.7 (no description available)
 mysql-server-core-5.7 MySQL database server binaries

You have to reinstall the mysql-client-core-5.7 mysql-server-5.7 mysql-server-core-5.7 packages in exactly the same version that was installed, and then it should be possible to remove it again.

Maybe you still have the files stored locally.
What is the output of

ls -l /var/lib/apt/archives/*mysql*

chinkleet shukla (chinks22) said : #6

below is the output of the comand :

ls -l /var/lib/apt/archives/*mysql*
ls: cannot access '/var/lib/apt/archives/*mysql*': No such file or directory

tried installing these packages however unable to do so, because of the umet dependencies:

sudo apt install mysql-server-5.7
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 mysql-server-5.7 : PreDepends: mysql-common (>= 5.5) but it is not going to be installed
                    Depends: mysql-client-5.7 (>= 5.7.33-0ubuntu0.18.04.1) but it is not going to be installed
                    Depends: mysql-common (>= 5.8+1.0.4~) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

sudo apt install mysql-server-core-5.7
Reading package lists... Done
Building dependency tree
Reading state information... Done
mysql-server-core-5.7 is already the newest version (5.7.33-0ubuntu0.18.04.1).
mysql-server-core-5.7 set to manually installed.
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 mysql-server-5.7 : PreDepends: mysql-common (>= 5.5) but it is not going to be installed
                    Depends: mysql-client-5.7 (>= 5.7.33-0ubuntu0.18.04.1) but it is not going to be installed
                    Depends: mysql-common (>= 5.8+1.0.4~) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

sudo apt install mysql-client-core-5.7
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 mysql-server-5.7 : PreDepends: mysql-common (>= 5.5) but it is not going to be installed
                    Depends: mysql-client-5.7 (>= 5.7.33-0ubuntu0.18.04.1) but it is not going to be installed
                    Depends: mysql-common (>= 5.8+1.0.4~) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

sudo apt install mysql-client-5.7
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 mysql-client-5.7 : Depends: mysql-common (>= 5.5) but it is not going to be installed
 mysql-server-5.7 : PreDepends: mysql-common (>= 5.5) but it is not going to be installed
                    Depends: mysql-common (>= 5.8+1.0.4~) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Initially i have installed the same version,now it

chinkleet shukla (chinks22) said : #8

below is the result of the commands:

~/Downloads/Mysql$ ls
mysql-client-core-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb
mysql-common_5.8+1.0.5ubuntu2_all.deb mysql-server-core-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

~/Downloads/Mysql$ sudo dpkg --force-all -i mysql-common*.deb
[sudo] password for extramarks:
dpkg: warning: files list file for package 'mysql-server-core-5.7' missing; assuming package has no files currently installed
(Reading database ... 245563 files and directories currently installed.)
Preparing to unpack mysql-common_5.8+1.0.5ubuntu2_all.deb ...
Unpacking mysql-common (5.8+1.0.5ubuntu2) over (5.8+1.0.4) ...
Setting up mysql-common (5.8+1.0.5ubuntu2) ...

Configuration file '/etc/mysql/conf.d/mysql.cnf', does not exist on system.
Installing new config file as you requested.

Configuration file '/etc/mysql/conf.d/mysqldump.cnf', does not exist on system.
Installing new config file as you requested.

Configuration file '/etc/mysql/my.cnf.fallback', does not exist on system.
Installing new config file as you requested.
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
~/Downloads/Mysql$ sudo dpkg --force-all -i mysql-*5.7*.deb
Selecting previously unselected package mysql-client-core-5.7.
dpkg: warning: files list file for package 'mysql-server-core-5.7' missing; assuming package has no files currently installed
(Reading database ... 245563 files and directories currently installed.)
Preparing to unpack mysql-client-core-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.32-0ubuntu0.18.04.1) ...
Preparing to unpack mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb ...
Can't locate Debconf/Db.pm in @INC (you may need to install the Debconf::Db module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/debconf/frontend line 6.
BEGIN failed--compilation aborted at /usr/share/debconf/frontend line 6.
dpkg: error processing archive mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb (--install):
 new mysql-server-5.7 package pre-installation script subprocess returned error exit status 2
Can't locate Debconf/Db.pm in @INC (you may need to install the Debconf::Db module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/debconf/frontend line 6.
BEGIN failed--compilation aborted at /usr/share/debconf/frontend line 6.
dpkg: error while cleaning up:
 new mysql-server-5.7 package post-removal script subprocess returned error exit status 2
dpkg: warning: downgrading mysql-server-core-5.7 from 5.7.33-0ubuntu0.18.04.1 to 5.7.32-0ubuntu0.18.04.1
Preparing to unpack mysql-server-core-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.32-0ubuntu0.18.04.1) over (5.7.33-0ubuntu0.18.04.1) ...
Setting up mysql-client-core-5.7 (5.7.32-0ubuntu0.18.04.1) ...
Setting up mysql-server-core-5.7 (5.7.32-0ubuntu0.18.04.1) ...
Processing triggers for man-db (2.8.3-2) ...
Errors were encountered while processing:
 mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Manfred Hampl (m-hampl) said : #9

Run the commands

sudo apt install debconf -f
sudo dpkg --audit

and copy/paste all output into the question document that we can see.

chinkleet shukla (chinks22) said : #10

(base) extramarks@extramarks-Latitude-3400:~$ sudo apt install debconf -f
[sudo] password for extramarks:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 debconf-i18n : Depends: debconf (= 1.5.66) but 1.5.66ubuntu1 is to be installed
 debconf-utils : Depends: debconf (= 1.5.66) but 1.5.66ubuntu1 is to be installed
 mysql-server-5.7 : Depends: mysql-client-5.7 (>= 5.7.33-0ubuntu0.18.04.1) but it is not going to be installed
                    Depends: mysql-server-core-5.7 (= 5.7.33-0ubuntu0.18.04.1) but 5.7.32-0ubuntu0.18.04.1 is to be installed
 python3-debconf : Depends: debconf (= 1.5.66) but 1.5.66ubuntu1 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

(base) extramarks@extramarks-Latitude-3400:~$ sudo dpkg --audit
The following packages are in a mess due to serious problems during
installation. They must be reinstalled for them (and any packages
that depend on them) to function properly:
 mysql-server-5.7 (no description available)

The following packages are missing the list control file in the
database, they need to be reinstalled:
 mysql-server-5.7 (no description available)

The following packages are missing the md5sums control file in the
database, they need to be reinstalled:
 mysql-server-5.7 (no description available)

Manfred Hampl (m-hampl) said : #11

Try

sudo apt install debconf=1.5.66 -f

and report the results

chinkleet shukla (chinks22) said : #12

(base) extramarks@extramarks-Latitude-3400:~$ sudo apt install debconf=1.5.66 -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
debconf is already the newest version (1.5.66).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 mysql-server-5.7 : Depends: mysql-client-5.7 (>= 5.7.33-0ubuntu0.18.04.1) but it is not going to be installed
                    Depends: mysql-server-core-5.7 (= 5.7.33-0ubuntu0.18.04.1) but 5.7.32-0ubuntu0.18.04.1 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Manfred Hampl (m-hampl) said : #13

Try the following:

download
https://launchpad.net/ubuntu/+archive/primary/+files/debconf_1.5.66_all.deb

and re-install it with

sudo dpkg -i debconf_1.5.66_all.deb

Then list the current status of the mysql packages with the command

dpkg -l | grep mysql

and copy/paste the output that we can check.

chinkleet shukla (chinks22) said : #14

(base) extramarks@extramarks-Latitude-3400:~/Downloads$ cd Mysql/
(base) extramarks@extramarks-Latitude-3400:~/Downloads/Mysql$ ls
debconf_1.5.66_all.deb mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb
mysql-client-core-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb mysql-server-core-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb
mysql-common_5.8+1.0.5ubuntu2_all.deb
(base) extramarks@extramarks-Latitude-3400:~/Downloads/Mysql$ sudo dpkg -i debconf_1.5.66_all.deb
[sudo] password for extramarks:
(Reading database ... 245671 files and directories currently installed.)
Preparing to unpack debconf_1.5.66_all.deb ...
Unpacking debconf (1.5.66) over (1.5.66) ...
Setting up debconf (1.5.66) ...
Processing triggers for man-db (2.8.3-2) ...
(base) extramarks@extramarks-Latitude-3400:~/Downloads/Mysql$ dpkg -l | grep mysql
ii mysql-client-core-5.7 5.7.32-0ubuntu0.18.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.cnf
iHR mysql-server-5.7 5.7.32-0ubuntu0.18.04.1 amd64 (no description available)
ii mysql-server-core-5.7 5.7.32-0ubuntu0.18.04.1 amd64 MySQL database server binaries

Manfred Hampl (m-hampl) said : #15

What output do you now receive for

cd ~/Downloads/Mysql
sudo dpkg -i mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb

Manfred Hampl (m-hampl) said : #16

If this fails, try again with

sudo DEBIAN_SCRIPT_DEBUG=true dpkg -i mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb

and copy/paste all output.

chinkleet shukla (chinks22) said : #17

below is the output for : sudo dpkg -i mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb

(base) extramarks@extramarks-Latitude-3400:~/Downloads/Mysql$ sudo dpkg -i mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb
[sudo] password for extramarks:
(Reading database ... 245671 files and directories currently installed.)
Preparing to unpack mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb ...
Can't locate Debian/AdduserCommon.pm in @INC (you may need to install the Debian::AdduserCommon module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/sbin/addgroup line 34.
BEGIN failed--compilation aborted at /usr/sbin/addgroup line 34.
dpkg: error processing archive mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb (--install):
 new mysql-server-5.7 package pre-installation script subprocess returned error exit status 2
Errors were encountered while processing:
 mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

(base) extramarks@extramarks-Latitude-3400:~/Downloads/Mysql$ sudo DEBIAN_SCRIPT_DEBUG=true dpkg -i mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb
(Reading database ... 245671 files and directories currently installed.)
Preparing to unpack mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb ...
+ DEBIAN_SCRIPT_TRACE=1
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
+ echo '#42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/config configure 5.7.32-0ubuntu0.18.04.1' '1>&2'
#42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/config configure 5.7.32-0ubuntu0.18.04.1 1>&2

# Beware that there are two ypwhich one of them needs the 2>/dev/null!
if test -n "`which ypwhich 2>/dev/null`" && ypwhich >/dev/null 2>&1; then
  db_input high mysql-server-5.6/nis_warning || true
  db_go
fi
++ which ypwhich
+ test -n ''

# only ask this question on fresh installs, during "reconfiguration" and when
# not upgrading from an existing 5.0 installation.
# there is also an additional check for empty root passwords in the
# postinst script when the tools are available for us to use.
if [ "$1" = "configure" ] && [ ! -e "/var/lib/mysql/mysql" ]; then
  while :; do
    RET=""
    db_input medium mysql-server/root_password || true
    db_go
    db_get mysql-server/root_password
    # if password isn't empty we ask for password verification
    if [ -z "$RET" ]; then
      db_fset mysql-server/root_password seen false
      db_fset mysql-server/root_password_again seen false
      break
    fi
    ROOT_PW="$RET"
    db_input medium mysql-server/root_password_again || true
    db_go
    db_get mysql-server/root_password_again
    if [ "$RET" == "$ROOT_PW" ]; then
      ROOT_PW=''
      break
    fi
    db_fset mysql-server/password_mismatch seen false
    db_input critical mysql-server/password_mismatch
    db_set mysql-server/root_password ""
    db_set mysql-server/root_password_again ""
    db_go
  done
fi
+ '[' configure = configure ']'
+ '[' '!' -e /var/lib/mysql/mysql ']'
+ :
+ RET=
+ db_input medium mysql-server/root_password
+ _db_cmd 'INPUT medium' mysql-server/root_password
+ _db_internal_IFS='
'
+ IFS=' '
+ printf '%s\n' 'INPUT medium mysql-server/root_password'
+ IFS='
'
+ IFS='
'
+ read -r _db_internal_line
+ RET='30 question skipped'
+ case ${_db_internal_line%%[ ]*} in
+ return 30
+ true
+ db_go
+ _db_cmd 'GO '
+ _db_internal_IFS='
'
+ IFS=' '
+ printf '%s\n' 'GO '
+ IFS='
'
+ IFS='
'
+ read -r _db_internal_line
+ RET=ok
+ case ${_db_internal_line%%[ ]*} in
+ return 0
+ db_get mysql-server/root_password
+ _db_cmd 'GET mysql-server/root_password'
+ _db_internal_IFS='
'
+ IFS=' '
+ printf '%s\n' 'GET mysql-server/root_password'
+ IFS='
'
+ IFS='
'
+ read -r _db_internal_line
+ RET=
+ case ${_db_internal_line%%[ ]*} in
+ return 0
+ '[' -z '' ']'
+ db_fset mysql-server/root_password seen false
+ _db_cmd 'FSET mysql-server/root_password' seen false
+ _db_internal_IFS='
'
+ IFS=' '
+ printf '%s\n' 'FSET mysql-server/root_password seen false'
+ IFS='
'
+ IFS='
'
+ read -r _db_internal_line
+ RET=false
+ case ${_db_internal_line%%[ ]*} in
+ return 0
+ db_fset mysql-server/root_password_again seen false
+ _db_cmd 'FSET mysql-server/root_password_again' seen false
+ _db_internal_IFS='
'
+ IFS=' '
+ printf '%s\n' 'FSET mysql-server/root_password_again seen false'
+ IFS='
'
+ IFS='
'
+ read -r _db_internal_line
+ RET=false
+ case ${_db_internal_line%%[ ]*} in
+ return 0
+ break
+ DEBIAN_SCRIPT_TRACE=1
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
+ echo '#42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/preinst upgrade 5.7.32-0ubuntu0.18.04.1 5.7.32-0ubuntu0.18.04.1' '1>&2'
#42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/preinst upgrade 5.7.32-0ubuntu0.18.04.1 5.7.32-0ubuntu0.18.04.1 1>&2

export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
+ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin:/usr/sbin:/bin:/usr/bin
+ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin:/usr/sbin:/bin:/usr/bin
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
+ MYADMIN='/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf'
DATADIR=/var/lib/mysql
+ DATADIR=/var/lib/mysql
LOGDIR=/var/log/mysql
+ LOGDIR=/var/log/mysql
UPGRADEDIR=/var/lib/mysql-upgrade
+ UPGRADEDIR=/var/lib/mysql-upgrade

# To avoid having hardcoded paths in the script, we do a search on the path, as suggested at:
# https://www.debian.org/doc/manuals/developers-reference/ch06.en.html#bpp-debian-maint-scripts
pathfind() {
  OLDIFS="$IFS"
  IFS=:
  for p in $PATH; do
    if [ -x "$p/$*" ]; then
      IFS="$OLDIFS"
      return 0
    fi
  done
  IFS="$OLDIFS"
  return 1
}

# Try to stop the server in a sane way. If it does not success let the admin
# do it himself. No database directories should be removed while the server
# is running! Another mysqld in e.g. a different chroot is fine for us.
stop_server() {
    if [ ! -x /etc/init.d/mysql ]; then return; fi

    set +e
    if pathfind invoke-rc.d; then
      cmd="invoke-rc.d mysql stop"
    else
      cmd="/etc/init.d/mysql stop"
    fi
    $cmd
    errno=$?
    set -e

    # 0=ok, 100=no init script (fresh install)
    if [ "$errno" != 0 -a "$errno" != 100 ]; then
      echo "${cmd/ */} returned $errno" 1>&2
      echo "There is a MySQL server running, but we failed in our attempts to stop it." 1>&2
      echo "Stop it yourself and try again!" 1>&2
      db_stop
      exit 1
    fi
}

################################ main() ##########################

this_version=5.7
+ this_version=5.7

# Abort if an NDB cluster is in use.
if egrep -qi -r '^[^#]*ndb.connectstring|^[[:space:]]*\[[[:space:]]*ndb_mgmd' /etc/mysql/; then
  db_fset mysql-server/no_upgrade_when_using_ndb seen false || true
  db_input high mysql-server/no_upgrade_when_using_ndb || true
  db_go
  db_stop
  exit 1
fi
+ egrep -qi -r '^[^#]*ndb.connectstring|^[[:space:]]*\[[[:space:]]*ndb_mgmd' /etc/mysql/

# Abort if skip-bdb option is enabled, required for 5.0 -> 5.1 upgrades.
#TODO

# Safe the user from stupidities.
is_downgrade_attempt=0
+ is_downgrade_attempt=0
for i in `ls $DATADIR/debian-*.flag 2>/dev/null`; do
  found_version=`echo $i | sed 's/.*debian-\([0-9\.]\+\).flag/\1/'`
  if dpkg --compare-versions "$this_version" '<<' "$found_version"; then
    is_downgrade_attempt=1
    break;
  fi
done
++ ls '/var/lib/mysql/debian-*.flag'
if [ "$is_downgrade_attempt" = 1 ]; then
  if [ -e /etc/mysql/FROZEN -o -h /etc/mysql/FROZEN ]; then
    echo "Warning: /etc/mysql/FROZEN already exists" >&2
  else
    ln -s ../../usr/share/doc/mysql-common/frozen-mode/downgrade /etc/mysql/FROZEN
  fi
  db_fset mysql-server-$this_version/installation_freeze_mode_active seen false || true
  db_input critical mysql-server-$this_version/installation_freeze_mode_active || true
  db_go
  db_stop
  echo "Downgrade from (at least) $found_version to $this_version is not possible." 1>&2
  echo "Packaging maintenance of MySQL will stop and the daemon disabled to prevent damage to your system." 1>&2
  echo "For help, see /etc/mysql/FROZEN" 1>&2
  exit 0
fi
+ '[' 0 = 1 ']'

# to be sure
stop_server
+ stop_server
+ '[' '!' -x /etc/init.d/mysql ']'
+ return

# If we use NIS then errors should be tolerated. It's up to the
# user to ensure that the mysql user is correctly setup.
# Beware that there are two ypwhich one of them needs the 2>/dev/null!
if test -n "`which ypwhich 2>/dev/null`" && ypwhich >/dev/null 2>&1; then
  set +e
fi
++ which ypwhich
+ test -n ''

#
# Now we have to ensure the following state:
# /etc/passwd: mysql:x:100:101:MySQL Server:/nonexistent:/bin/false
# /etc/group: mysql:x:101:
#
# Sadly there could any state be present on the system so we have to
# modify everything carefully i.e. not doing a chown before creating
# the user etc...
#

# creating mysql group if he isn't already there
if ! getent group mysql >/dev/null; then
  # Adding system group: mysql.
 addgroup --system mysql >/dev/null
fi
+ getent group mysql
+ addgroup --system mysql
Can't locate Debian/AdduserCommon.pm in @INC (you may need to install the Debian::AdduserCommon module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/sbin/addgroup line 34.
BEGIN failed--compilation aborted at /usr/sbin/addgroup line 34.
dpkg: error processing archive mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb (--install):
 new mysql-server-5.7 package pre-installation script subprocess returned error exit status 2
+ DEBIAN_SCRIPT_TRACE=1
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
+ echo '#42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/postrm abort-upgrade 5.7.32-0ubuntu0.18.04.1 5.7.32-0ubuntu0.18.04.1' '1>&2'
#42#DEBUG# RUNNING /var/lib/dpkg/tmp.ci/postrm abort-upgrade 5.7.32-0ubuntu0.18.04.1 5.7.32-0ubuntu0.18.04.1 1>&2

mysql_cfgdir=/etc/mysql
+ mysql_cfgdir=/etc/mysql
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
+ MYADMIN='/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf'

# To avoid having hardcoded paths in the script, we do a search on the path, as suggested at:
# https://www.debian.org/doc/manuals/developers-reference/ch06.en.html#bpp-debian-maint-scripts
pathfind() {
  OLDIFS="$IFS"
  IFS=:
  for p in $PATH; do
    if [ -x "$p/$*" ]; then
      IFS="$OLDIFS"
      return 0
    fi
  done
  IFS="$OLDIFS"
  return 1
}

# Try to stop the server in a sane way. If it does not success let the admin
# do it himself. No database directories should be removed while the server
# is running!
stop_server() {
  set +e
  if pathfind invoke-rc.d; then
    invoke-rc.d mysql stop
  else
    /etc/init.d/mysql stop
  fi
  errno=$?
  set -e

  if [ "$?" != 0 ]; then
    echo "Trying to stop the MySQL server resulted in exitcode $?." 1>&2
    echo "Stop it yourself and try again!" 1>&2
    exit 1
  fi
}

case "$1" in
  purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
    if [ -n "`$MYADMIN ping 2>/dev/null`" ]; then
      stop_server
      sleep 2
    fi
  ;;
  *)
    echo "postrm called with unknown argument '$1'" 1>&2
    exit 1
  ;;
esac
+ case "$1" in
++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
+ '[' -n '' ']'

# New packaging paradigm for my.cnf as of Dec-2014 for sharing mysql
# variants in Ubuntu.
case "$1" in
  remove|disappear)
    [ -x /usr/share/mysql-common/configure-symlinks ] && /usr/share/mysql-common/configure-symlinks remove mysql "$mysql_cfgdir/mysql.cnf"
  ;;
esac
+ case "$1" in

#
# - When purging, ask if data files should also be removed
#
if [ "$1" = "purge" ]; then
  # we remove the mysql user only after all his owned files are purged
  rm -f /var/log/mysql.{log,err}{,.0,.[1234567].gz}
  rm -rf /var/log/mysql

  db_input high mysql-server-5.7/postrm_remove_databases || true
  db_go || true
  db_get mysql-server-5.7/postrm_remove_databases || true
  if [ "$RET" = "true" ]; then
    # never remove the debian.cnf when the databases are still existing
    # else we ran into big trouble on the next install!
    rm -f /etc/mysql/debian.cnf
    rm -rf /var/lib/mysql
    rm -rf /var/lib/mysql-files
    rm -rf /var/lib/mysql-keyring
    userdel mysql || true
  fi
fi
+ '[' abort-upgrade = purge ']'

# Automatically added by dh_installinit/11.1.6ubuntu1
if [ "$1" = "purge" ] ; then
 update-rc.d mysql remove >/dev/null
fi
+ '[' abort-upgrade = purge ']'

# In case this system is running systemd, we make systemd reload the unit files
# to pick up changes.
if [ -d /run/systemd/system ] ; then
 systemctl --system daemon-reload >/dev/null || true
fi
+ '[' -d /run/systemd/system ']'
+ systemctl --system daemon-reload
# End automatically added section
# Automatically added by dh_systemd_enable/11.1.6ubuntu1
if [ "$1" = "remove" ]; then
 if [ -x "/usr/bin/deb-systemd-helper" ]; then
  deb-systemd-helper mask 'mysql.service' >/dev/null || true
 fi
fi
+ '[' abort-upgrade = remove ']'

if [ "$1" = "purge" ]; then
 if [ -x "/usr/bin/deb-systemd-helper" ]; then
  deb-systemd-helper purge 'mysql.service' >/dev/null || true
  deb-systemd-helper unmask 'mysql.service' >/dev/null || true
 fi
fi
+ '[' abort-upgrade = purge ']'
# End automatically added section
# Automatically added by dh_installdebconf/11.1.6ubuntu1
if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
 . /usr/share/debconf/confmodule
 db_purge
fi
+ '[' abort-upgrade = purge ']'
# End automatically added section
# Automatically added by dh_apparmor/2.12-4ubuntu5.1
if [ "$1" = "purge" ] && ! [ -e "/etc/apparmor.d/usr.sbin.mysqld" ] ; then
    rm -f "/etc/apparmor.d/disable/usr.sbin.mysqld" || true
    rm -f "/etc/apparmor.d/force-complain/usr.sbin.mysqld" || true
    rm -f "/etc/apparmor.d/local/usr.sbin.mysqld" || true
    rmdir /etc/apparmor.d/disable 2>/dev/null || true
    rmdir /etc/apparmor.d/local 2>/dev/null || true
    rmdir /etc/apparmor.d 2>/dev/null || true
fi
+ '[' abort-upgrade = purge ']'
# End automatically added section

exit 0
+ exit 0
Errors were encountered while processing:
 mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb

Manfred Hampl (m-hampl) said : #18

The failure happens at

+ addgroup --system mysql
Can't locate Debian/AdduserCommon.pm in @INC (you may need to install the Debian::AdduserCommon module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/sbin/addgroup line 34.
BEGIN failed--compilation aborted at /usr/sbin/addgroup line 34.

What output do you receive for the command

sudo addgroup --system mysql

chinkleet shukla (chinks22) said : #19

(base) extramarks@extramarks-Latitude-3400:~$ sudo addgroup --system mysql
[sudo] password for extramarks:
Can't locate Debian/AdduserCommon.pm in @INC (you may need to install the Debian::AdduserCommon module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/sbin/addgroup line 34.
BEGIN failed--compilation aborted at /usr/sbin/addgroup line 34.

Manfred Hampl (m-hampl) said : #20

Ok. This shows that mysql is not the culprit, but there is something broken in other parts of your operating system.

Try reinstalling the adduser package

download
https://launchpad.net/ubuntu/+archive/primary/+files/adduser_3.116ubuntu1_all.deb
and install it with
sudo dpkg -i adduser_3.116ubuntu1_all.deb

Then try again:

sudo addgroup --system mysql

and report the results.

chinkleet shukla (chinks22) said : #21

(base) extramarks@extramarks-Latitude-3400:~/Downloads/Mysql$ sudo dpkg -i adduser_3.116ubuntu1_all.deb
[sudo] password for extramarks:
eSorry, try again.
[sudo] password for extramarks:
Sorry, try again.
[sudo] password for extramarks:
(Reading database ... 245671 files and directories currently installed.)
Preparing to unpack adduser_3.116ubuntu1_all.deb ...
Unpacking adduser (3.116ubuntu1) over (3.116ubuntu1) ...
Setting up adduser (3.116ubuntu1) ...
Processing triggers for man-db (2.8.3-2) ...
(base) extramarks@extramarks-Latitude-3400:~/Downloads/Mysql$
(base) extramarks@extramarks-Latitude-3400:~/Downloads/Mysql$
(base) extramarks@extramarks-Latitude-3400:~/Downloads/Mysql$ sudo add
add-apt-repository addgnupghome addgroup addpart addr2line add-shell adduser
(base) extramarks@extramarks-Latitude-3400:~/Downloads/Mysql$ sudo addgroup --system mysql
Adding group `mysql' (GID 127) ...
Done.

Manfred Hampl (m-hampl) said : #22

ok, adduser works again. Now try installing mysql

sudo dpkg -i mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb

and report the results.

chinkleet shukla (chinks22) said : #23

(base) extramarks@extramarks-Latitude-3400:~/Downloads/Mysql$ sudo dpkg -i mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb
[sudo] password for extramarks:
(Reading database ... 245671 files and directories currently installed.)
Preparing to unpack mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.32-0ubuntu0.18.04.1) over (5.7.32-0ubuntu0.18.04.1) ...
dpkg: dependency problems prevent configuration of mysql-server-5.7:
 mysql-server-5.7 depends on mysql-client-5.7 (>= 5.7.32-0ubuntu0.18.04.1); however:
  Package mysql-client-5.7 is not installed.

dpkg: error processing package mysql-server-5.7 (--install):
 dependency problems - leaving unconfigured
Processing triggers for ureadahead (0.100.0-20) ...
ureadahead will be reprofiled on next reboot
Processing triggers for systemd (237-3ubuntu10.3) ...
Processing triggers for man-db (2.8.3-2) ...
Errors were encountered while processing:
 mysql-server-5.7

Best Manfred Hampl (m-hampl) said : #24

It seems I missed one

download
https://launchpad.net/ubuntu/+archive/primary/+files/mysql-client-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb

and then

sudo dpkg -i mysql-client-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb
sudo dpkg -i mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb

and report the results.

chinkleet shukla (chinks22) said : #25

(base) extramarks@extramarks-Latitude-3400:~/Downloads/Mysql$ sudo dpkg -i mysql-client-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb
Selecting previously unselected package mysql-client-5.7.
(Reading database ... 245757 files and directories currently installed.)
Preparing to unpack mysql-client-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.32-0ubuntu0.18.04.1) ...
Setting up mysql-client-5.7 (5.7.32-0ubuntu0.18.04.1) ...
Processing triggers for man-db (2.8.3-2) ...
(base) extramarks@extramarks-Latitude-3400:~/Downloads/Mysql$ sudo dpkg -i mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb
(Reading database ... 245791 files and directories currently installed.)
Preparing to unpack mysql-server-5.7_5.7.32-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.32-0ubuntu0.18.04.1) over (5.7.32-0ubuntu0.18.04.1) ...
Setting up mysql-server-5.7 (5.7.32-0ubuntu0.18.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)
AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/usr.sbin.mysqld at line 9: Could not open 'abstractions/mysql'
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for systemd (237-3ubuntu10.3) ...
Processing triggers for man-db (2.8.3-2) ...

chinkleet shukla (chinks22) said : #26

It worked, just checked, MySQL-service is running and also other packages are getting installed:

(base) extramarks@extramarks-Latitude-3400:~/Downloads/Mysql$ systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2021-02-10 00:43:05 IST; 7min ago
 Main PID: 5977 (mysqld)
    Tasks: 27 (limit: 4915)
   CGroup: /system.slice/mysql.service
           └─5977 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid

Feb 10 00:43:04 extramarks-Latitude-3400 systemd[1]: Starting MySQL Community Server...
Feb 10 00:43:05 extramarks-Latitude-3400 systemd[1]: Started MySQL Community Server.

(base) extramarks@extramarks-Latitude-3400:~$ sudo apt install whois
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  whois
0 upgraded, 1 newly installed, 0 to remove and 361 not upgraded.
Need to get 43.7 kB of archives.
After this operation, 262 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 whois amd64 5.3.0 [43.7 kB]
Fetched 43.7 kB in 17s (2,606 B/s)
Selecting previously unselected package whois.
(Reading database ... 245791 files and directories currently installed.)
Preparing to unpack .../archives/whois_5.3.0_amd64.deb ...
Unpacking whois (5.3.0) ...
Setting up whois (5.3.0) ...
Processing triggers for man-db (2.8.3-2) ...
(base) extramarks@extramarks-Latitude-3400:~$ who
who whoami whois whoopsie whoopsie-preferences

Manfred Hampl (m-hampl) said : #27

Success! The package management system is back in a consistent state.

"0 upgraded, 1 newly installed, 0 to remove and 361 not upgraded."
There are 361 package updates available. you should consider installing them

If this problem has been resolved, then you should set the status of this question document to "solved".

chinkleet shukla (chinks22) said : #28

Thanks a lot for your help, Manfred!
Problem Solved

chinkleet shukla (chinks22) said : #29

Thanks Manfred Hampl, that solved my question.