0

How do I uninstall MySQL in WSL?

I have version 5.7.4 installed. After reading over the changes for upgrading to the latest 5.7.x version so I could upgrade to 8.0 (there's a minimum requirement of 5.7.9 to upgrade to 8.0), I figured it would be easier to just uninstall MySQL and start over (I have nothing worth saving from playing around with it previously).

I tried running the following commands (as per this post and this one) and got the following responses:

$ sudo apt remove mysql mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package mysql
$ sudo apt-get remove --purge *mysql*
zsh: no matches found: *mysql*
$ sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
zsh: no matches found: mysql-server-core-*

After running those, I'm still able to start and stop my server with the following commands (note that these are not necessarily the usual systemd commands because I'm in WSL2):

  • sudo /etc/init.d/mysql start
  • mysqladmin -u root -p shutdown

Unsure if this is relevant, but even when the server is running I'm not seeing the socket when I enter sudo find / -type s as suggested by this post.

I'm wondering it'd be okay to just delete what files I can find manually, but that seems like a bad idea

  • /var/lib/mysql/
  • /usr/share/mysql/
  • /usr/lib/mysql/
coniferous
  • 67
  • 8
  • If you do a `*mysql*`, you ask the shell to replace this pattern by the list of files matching the pattern. Not surprisingly there is no such a file. What happens afterwards, depends on how you have configured your shell, and of course this can mean that your bash and your zsh behave differently. For instance I have configured my shell so that in this case it spits out an error message and aborts, because this is the behaviour I **want** to have. – user1934428 Jan 13 '23 at 08:45

1 Answers1

1

The problem was using zsh as a shell. I successfully removed MySQL with sudo apt-get remove --purge '*mysql*'

coniferous
  • 67
  • 8
  • 1
    Kind of funny I was having the exact same problem in Mysql 8.0. I had to disable the .service, reload the systemd daemon and then kill the process before being able to remove it. – Jetto Martínez Jan 12 '23 at 17:23