Ruka
2 min readJan 3, 2022

[Ubuntu 20.04][MySQL5.7]Problems installing mysql5.7 on Ubuntu 20.04

E: Sub-process /usr/bin/dpkg returned an error code (1)
by n 2022.01.03

First, you’ll need to follow this artical cause installing mysql5.7 to ubuntu 20.04 requires lots of manual settings.

https://computingforgeeks.com/how-to-install-mysql-on-ubuntu-focal/

Or follow this artical if you need to down grade from MySQL8

https://www.digitalocean.com/community/questions/how-can-i-properly-downgrade-from-mysql-8-to-5-7-on-ubuntu-20-04

After this, you have a chance to meet the same error msg as I did.

E: Sub-process /usr/bin/dpkg returned an error code (1)

Which I found out the sequence for installing mysql-server should be

sudo apt-get install mysql-client=5.7*
sudo apt-get install mysql-community-client=5.7*
sudo apt-get install mysql-community-server=5.7*
sudo apt-get install mysql-server=5.7*

https://www.youtube.com/watch?v=C0XVEB5Y80c&ab_channel=ATOM

But if you meet the same error in installing client which show error like the following screen

mysqld: Can't read dir of '/etc/mysql/conf.d/'

You Could look into the folder and check the folders in it, and copy mysql.conf.d as conf.d by running the following command

cd /etc/mysql
sudo cp -r mysql.conf.d conf.d

Then you’ll find out all the installation works normal.

Like this story if you fix the issue =]