0

I tried to remove the mysql-server but i got this problem

0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 111 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 239230 files and directories currently installed.)
Removing mysql-server (8.0.21-0ubuntu0.20.04.4) ...
Setting up mysql-server-8.0 (8.0.21-0ubuntu0.20.04.4) ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
dpkg: error processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
 mysql-server-8.0
E: Sub-process /usr/bin/dpkg returned an error code (1)

and when i tried to install i got problem like this

firdausyah22@lenovo110:~$ sudo apt install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfprint-2-tod1
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  mysql-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/9.552 B of archives.
After this operation, 111 kB of additional disk space will be used.
Selecting previously unselected package mysql-server.
(Reading database ... 239228 files and directories currently installed.)
Preparing to unpack .../mysql-server_8.0.21-0ubuntu0.20.04.4_all.deb ...
Unpacking mysql-server (8.0.21-0ubuntu0.20.04.4) ...
Setting up mysql-server-8.0 (8.0.21-0ubuntu0.20.04.4) ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
dpkg: error processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 2
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 No apport report written because the error message indicates its a followup error from a previous failure. Errors were encountered while processing: mysql-server-8.0 mysql-server E: Sub-process /usr/bin/dpkg returned an error code (1)

previously I used XAMPP. I have removed XAMPP because I will use Nginx as a webserver, but I have a problem with MYSQL

how to solve this problem?

1 Answers1

0

It appears you have some broken dependencies. Try to purge everything to do with MySQL first with:

sudo apt purge mysql.*

Note the full-stop in front of the asterisk. This is a wildcard to say "apply to all packages starting with "mysql".

Note that the syntax is slightly different for newer releases of Ubuntu (with no full-stop):

sudo apt-get purge "mysql*"

Purging deletes not only the application but also all config, system and data files directly associated with it, so should give you a clean slate.

Then try to reinstall it:

sudo apt install mysql-server

If this is Ubuntu Server, you can also use the task selector to choose that you want to setup a LAMP server or just MySQL server:

sudo tasksel
  • IIRC, in newer versions of Ubuntu, globbing doesn't work with apt. – Kulfy Aug 19 '20 at 11:53
  • 1
    Yes, you're right. You have to use sudo apt-get purge "mysql*" to do that now. – Jeff Sereno Aug 20 '20 at 05:11
  • 1
    WARNING: DO NOT USE TASKSEL TO UNINSTALL PACKAGES. ONLY USE TASKSEL TO INSTALL!!! There is a serious bug that causes tasksel to uninstall most of the system if you use tasksel to uninstall packages. ONLY use tasksel for INSTALLING packages. – mchid Mar 03 '22 at 13:33
  • 1
    @mchid Actually wildcard was removed from APT when I wrote that comment. See this answer by Stephen for details. – Kulfy Mar 03 '22 at 14:01