Home > OS >  E: Sub-process /usr/bin/dpkg returned an error code (1) ( might be different than other errors like
E: Sub-process /usr/bin/dpkg returned an error code (1) ( might be different than other errors like

Time:03-05

sudo apt upgrade

I am recieving the following error

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 : Depends: mysql-server-8.0 but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Tried to fix-broken install

sudo apt -- fix-broken install

and recieving the following error

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  mysql-server-8.0
Suggested packages:
  mailx tinyca
The following NEW packages will be installed:
  mysql-server-8.0
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
1 not fully installed or removed.
Need to get 0 B/1,271 kB of archives.
After this operation, 1,479 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
dpkg: warning: files list file for package 'mysql
-server-core-8.0' missing; assuming package has n
o files currently installed
(Reading database ... 215620 files and directorie
s currently installed.)
Preparing to unpack .../mysql-server-8.0_8.0.28-0
ubuntu0.20.04.3_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service 
not loaded.
invoke-rc.d: initscript mysql, action "stop" fail
ed.
invoke-rc.d returned 5
There is a MySQL server running, but we failed in
 our attempts to stop it.
Stop it yourself and try again!
dpkg: error processing archive /var/cache/apt/arc
hives/mysql-server-8.0_8.0.28-0ubuntu0.20.04.3_am
d64.deb (--unpack):
 new mysql-server-8.0 package pre-installation sc
ript subprocess returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-8.0_8.0.28-
0ubuntu0.20.04.3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I tried with several blogs and solutions but i didn't got solution yet.

Ttied with sudo dpkg --configure -a , sudo apt-get install -f

CodePudding user response:

Finally i found a solution for my problem. run following commands in your terminal one after other

Here i have problem with mysql package. so i remove all mysql files

cd /usr/sbin/
./mysqld
sudo rm mysql*
 sudo apt-get remove --purge mysql-server mysql-client mysql-common -y
 sudo apt-get autoremove -y
 sudo rm -rf /etc/mysql
 sudo find / -iname 'mysql*' -exec rm -rf {} \;
 sudo systemctl stop mysql
 sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
 sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
 sudo apt autoremove
 sudo apt autoclean
 sudo apt update
 sudo apt upgrade
  • Related