Help SOLVED: Can't remove MySQL

Discussion in 'Technical Discussion' started by segamaniac, Apr 1, 2022.

Thread Status:
Not open for further replies.
  1. segamaniac

    segamaniac

    Oh chili dogs! Member
    UPDATE: I did this forum post's solution, I'm just gonna setup MySQL tomorrow, the thing is giving me a headache and kinda pissed me off a bit, I'll probably be in a better head space then. Btw, this is for a WordPress site I'm wanting to do.

    It's been a pain to setup MySQL on Kubuntu, I've tried the following command with no success:

    sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*

    In return, when I type yes to remove, I get this:

    (Reading database ... 462013 files and directories currently installed.)
    Removing mysql-server-8.0 (8.0.28-0ubuntu0.20.04.3) ...
    Failed to stop mysql.service: Unit mysql.service not loaded.
    invoke-rc.d: initscript mysql, action "stop" failed.
    dpkg: error processing package mysql-server-8.0 (--remove):
    installed mysql-server-8.0 package pre-removal script subprocess returned error exit st
    atus 1
    dpkg: too many errors, stopping
    Failed to stop mysql.service: Unit mysql.service not loaded.
    invoke-rc.d: initscript mysql, action "stop" failed.
    Failed to preset unit: File mysql.service: Link has been severed
    /usr/bin/deb-systemd-helper: error: systemctl preset failed on mysql.service: No such fi
    le or directory
    Failed to start mysql.service: Unit mysql.service not found.
    invoke-rc.d: initscript mysql, action "start" failed.
    Unit mysql.service could not be found.
    dpkg: error while cleaning up:
    installed mysql-server-8.0 package post-installation script subprocess returned error e
    xit status 1
    Errors were encountered while processing:
    mysql-server-8.0
    Processing was halted because there were too many errors.
    E: Sub-process /usr/bin/dpkg returned an error code (1)


    I seriously need help, I've been digging through hundreds of forums answers and they all ended up to something similar to this, any help is appreciated. Thank you in advance.
     
    Last edited: Apr 1, 2022
  2. Billy

    Billy

    RIP Oderus Urungus Member
    2,016
    90
    28
    Colorado, USA
    Indie games
    Welcome to the wonderful world of software, where you google shit until some random answer on StackOverflow happens to have the solution you need!

    You said you're setting up a WordPress site. Is there there a reason you're using Kubuntu instead of Ubuntu Server? Are you following a guide or something?
     
  3. segamaniac

    segamaniac

    Oh chili dogs! Member
    Yep, can totally relate with that lmao. The reason why I'm using Kubuntu instead of Ubuntu Server is that I was already using it to do average stuff for a while before I got my main computer working again, I would assume that Ubuntu Server would have all the necessary packages for things like that now that you mention. But yeah, I was kinda following WordPress's guide and this YouTube on setting up MySQL, but MySQL went haywire on me, so I'm kinda gonna somewhat start all over from the beginning. On another note, I have an SSH server set up on there so I can remotely access the terminal and files on my main, which comes in really handy, and I have Rygel running, so basically the computer has become sorta like a server for the house over time.
     
  4. Billy

    Billy

    RIP Oderus Urungus Member
    2,016
    90
    28
    Colorado, USA
    Indie games
    It's not so much that Ubuntu Server comes pre-installed with everything you need, more-so that Kubuntu comes pre-installed with things you don't, such as a GUI environment. Especially true if you're SSHing into it anyway. I was just curious if the guide you were following had you install Kubuntu for some strange reason.

    Don't be afraid to break stuff. Breaking and then fixing stuff is how you really learn.
     
  5. President Zippy

    President Zippy

    Zombies rule Belgium! Member
    I have two proposals to avoid future suffering, one which is quick and dirty, and another which is arduous but leaves you on permanent solid ground:

    1. Build a MySQL Docker image, which you can then pull onto any machine you want and run isolated from your root filesystem. You'll want to put the underlying storage of the DB on a separate volume from the container itself so you can build new images as needed.

    2. For a solution which requires 30hrs more work up-front but a lot less troubleshooting down the line, I would recommend using FreeBSD as your OS. Whether you use it as your host or run a FreeBSD VM is largely inconsequential, considering VirtualBox rarely has problems on Ubuntu or RHEL/Fedora. The semantics for a lot of things will seem alien at first, and it may cost you 20-50 extra hours of your life relearning how to do common administrative tasks, but there are several advantages:

    (a) Instead of bloated insecure Linux containers, you can use BSD jails to isolate the environment MySQL runs in. If you need a virtual IP address similar to containers, you can even use the vnet option.

    (b) The package manager is much more reliable (and also more secure), which would avoid the problem you are currently experiencing. If it can't uninstall cleanly, the maintainers won't accept it into the pkg repo.

    (c) The CLI semantics for services (daemons) is much simpler and more secure thanks to the use of a much simpler init system than systemd. Come to think of it, "pkg" is much more intuitive than "apt-get".

    (d) Everything is more secure on FreeBSD. This creates a learning curve which I'll elaborate on further, but the hierarchy of good software (descending) is:

    correctness -> security -> usability -> scalability -> efficiency​

    (e) The documentation is so clear and yet comprehensive, that you can find everything you need in the FreeBSD Handbook, in conjunction with the documentation of the software you're installing/configuring/using. Instead of dubious suggestions from random schmos on Stack Overflow or schmos like me, you can find answers backed by a much larger and more knowledgeable consensus. Googling through every step is great to hack things together quickly, but if you want to do something right, FreeBSD has handbooks. The FreeBSD man pages are also much better than Linux: compare the page for mmap(2) to see what I mean:

    https://www.freebsd.org/cgi/man.cgi....0-RELEASE+and+Ports&arch=default&format=html

    https://linux.die.net/man/2/mmap

    *NOTE: FreeBSD doesn't come preinstalled with a desktop environment or scripts to automate installing one. This is a massive pain in the neck, and I'm working on a script to automate away all the misery I suffered installed xfce the first time around. But there is also an alpha build of a BSD based on FreeBSD called "HelloSystem" which has a UI most similar to MacOS. I'm assuming you don't need a desktop environment, and FreeBSD is designed as a server OS with desktop usage being second-class, but if you want a DE it's possible to run one with 4-10hrs of extra elbow grease.​
     
    Last edited: Apr 2, 2022
  6. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    18,668
    614
    93
    Berkshire, England
    Learning Cymraeg
    Alternatively, just install Debian, which is designed as a server OS and will have far more packages available, as well as being more familiar and therefore not needing to learn BSD quirks.
     
  7. President Zippy

    President Zippy

    Zombies rule Belgium! Member
    I get the desire to avoid adopting a new OS that less than 0.1% of sysadmins have any experience with, but how is this easier than proposal (1) of keeping the existing Ubuntu environment and putting MySQL in a container to prevent a broken apt package from polluting the filesystem? For that matter, how does it solve the problem of the installer polluting the filesystem with artifacts that can't be cleaned up upon uninstallation?

    The whole point of making a pristine container image is that if something goes horribly wrong, you can make a new one instead of reinstalling the OS. If you keep the underlying data files for your MySQL instance in a separate Docker volume, you also don't lose them when you need to make a new installation.
     
  8. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    18,668
    614
    93
    Berkshire, England
    Learning Cymraeg
    It's not really, I was more responding to point 2.
     
  9. President Zippy

    President Zippy

    Zombies rule Belgium! Member
    Debian is still a Linux kernel with glibc, systemd, apt, openssl, and bash as its core utilities. What is the assurance MySQL will be any more reliable/secure/scalable on Debian than its derivatives, like Ubuntu and Kubuntu?
     
  10. Billy

    Billy

    RIP Oderus Urungus Member
    2,016
    90
    28
    Colorado, USA
    Indie games
    The point has been made: You could try different OS's, which may or may not make your life easier/more secure/etc. There's even ones tailored to running WordPress, apparently. However, if you're following a guide, I'd just go with whatever they recommend while you learn for now.
     
  11. segamaniac

    segamaniac

    Oh chili dogs! Member
    Gonna lock the thread since it's been fixed and so no back and forth goes on again, thanks for all the input btw! ;)
     
Thread Status:
Not open for further replies.