At first, I wanted to reinstall MySQL to repair
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
problem with command apt-get purge mysql-server
, apt-get purge mysql-client
etc. and manually removing folders like /var/lib/mysql/
, /etc/mysql/
etc.
While installing fresh MySQL package with apt-get install mysql-server
, I ran into this:
Preparing to unpack .../mysql-server-8.0_8.0.27-0ubuntu0.20.04.1_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
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/archives/mysql-server-8.0_8.0.27-0ubuntu0.20.04.1_amd64.deb (--unpack):
new mysql-server-8.0 package pre-installation script subprocess returned error exit status 1
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_8.0.27-0ubuntu0.20.04.1_all.deb ...
Unpacking mysql-server (8.0.27-0ubuntu0.20.04.1) ...
Errors were encountered while processing:
/var/cache/apt/archives/mysql-server-8.0_8.0.27-0ubuntu0.20.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
I tried to stop MySQL, but all I get is Failed to stop mysql.service: Unit mysql.service not loaded.
Command apt-get --fix-broken install
does not work either, due to the same problem as above.
mysql
command works, but it results in the same problem as in the beginning.