How To Uninstall MySQL on Ubuntu Linux

Introduction

On the previous post we learn How To Install MySQL on Ubuntu Linux. Now, we are going to learn how to remove or uninstall MySQL installation from the machine. There are many reason to uninstall database, you may want to free up some space, running issues with installation or replace with other type of database.

Uninstall MySQL Database

In the short version we want to follow steps to uninstall MySQL.  

  • 1. Check database version

    • mysql -V mysql Ver 14.14 Distrib 5.7.17, for Linux (x86_64) using EditLine wrapper. You may get different version of database.
  • 2. $sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-5.7 This is for mysql version 5.7

  • 3. Remove data directories ? Answer Yes if you dont want data directories anymore.

  • 4. # sudo rm -rf /etc/mysql /var/lib/mysql Remove mysql directories

  • 5. $sudo apt-get autoremove This will free up some space

  • 6. $sudo apt-get autoclean

   

Conclusion

Removing MySQL installation is a straight forward process. After MySQL remove you can install a new fresh MySQL database again or install another database.