1. Home
  2. MySQL Tutorials
  3. Uninstall MySQL 5.7 on Ubuntu 20.04 LTS

Uninstall MySQL 5.7 on Ubuntu 20.04 LTS

Previous article we have covered How to Install MySQL 5.7 on Ubuntu 20.04 LTS. In this tutorial , We are going to cover How to Uninstall MySQL 5.7 on Ubuntu 20.04 LTS Step by Step or any Cloud Instance like Amazon EC2, Azure VM, Google Compute Engine,etc. with preinstalled MySQL 5.7 and Ubuntu 20.04.

Prerequisites

  • Ubuntu 20.04 LTS System
  • SSH access with sudo privileges

First Uninstall MySQL package using below command.

sudo apt-get remove --purge mysql-server mysql-client mysql-common

Sample Output:

sudo apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 34 not upgraded.
user@fosstechnix:~$ sudo apt-get autoclean
Reading package lists... Done
Building dependency tree
Reading state information... Done
Del mysql-common 8.0.20-2ubuntu20.04 [94.4 kB]
Del mysql-community-server 8.0.20-2ubuntu20.04 [102 kB]
Del mysql-community-client-core 8.0.20-2ubuntu20.04 [1800 kB]
Del mysql-community-client 8.0.20-2ubuntu20.04 [3022 kB]
Del mysql-server 8.0.20-2ubuntu20.04 [90.7 kB]
Del mysql-client 8.0.20-2ubuntu20.04 [90.7 kB]
Del mysql-community-server-core 8.0.20-2ubuntu20.04 [22.1 MB]
user@fosstechnix:~$ sudo apt-get remove --purge mysql-server mysql-client mysql-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libmecab2 libtinfo5
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
mysql-client* mysql-common* mysql-community-client* mysql-community-server* mysql-server*
0 upgraded, 0 newly installed, 5 to remove and 32 not upgraded.
After this operation, 312 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 176579 files and directories currently installed.)
Removing mysql-server (5.7.30-1ubuntu18.04) ...
Removing mysql-community-server (5.7.30-1ubuntu18.04) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Removing mysql-client (5.7.30-1ubuntu18.04) ...
Removing mysql-community-client (5.7.30-1ubuntu18.04) ...
Removing mysql-common (5.8+1.0.5ubuntu2) ...
Processing triggers for man-db (2.9.1-1) ...
(Reading database ... 176370 files and directories currently installed.)
Purging configuration files for mysql-community-client (5.7.30-1ubuntu18.04) ...
Purging configuration files for mysql-common (5.8+1.0.5ubuntu2) ...
Purging configuration files for mysql-community-server (5.7.30-1ubuntu18.04) ...
.

It asks to remove data directories, if you want to remove, Enter on Yes button.

remove data directories

To clean local apt  pacakges.

sudo apt-get autoclean

By default mysql stores MySQL data files at /var/lib/mysql location. Run below commands to remove mysql backup files if you don’t need.

sudo rm -rf /var/lib/mysql

Conclusion

In this article, We have covered, How to Uninstall MySQL 5.7 on Ubuntu 20.04 LTS Step by Step.

How to Download and Install MySQL 5.7 on Ubuntu 18.04

Reference

MySQL Official Documentation

Tags

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.