May 18, 2019 by ChiuYau

  1. sudo apt-get remove --purge mysql*
  2. sudo apt-get purge mysql*
  3. sudo apt-get autoremove
  4. sudo apt-get autoclean
  5. sudo apt-get remove dbconfig-mysql
  6. sudo apt-get dist-upgrade
  7. sudo apt-get install mysql-serverYou will get this type of Pictures to remove MySQL from ubuntu after applying these steps.

How to remove MySQL Ubuntu (Alternative):

Due to different directories that we create in our operating system we got some problems with uninstalling MySQL. If this is still not working for you,

Follow these commands

service mysql stop

killall -KILL mysql mysqld_safe mysqld

apt-get --yes purge mysql*

apt-get --yes autoremove --purge

apt-get autoclean

deluser --remove-home mysql

delgroup mysql

rm -rf /etc/apparmor.d/abstractions/mysql /etc/apparmor.d/cache/usr.sbin.mysqld

/etc/mysql /var/lib/mysql /var/log/mysql* /var/log/upstart/mysql.log*

/var/run/mysqld ~/.mysql_history


If still not working for you, Please check any MySQL process running on your server, it can be view by using top command and service MySQL stop, otherwise, try step 3 before going through step 1 and 2.

Here is another way to remove MySQL ubuntu

Uninstall MySQL from Ubuntu and Install MariaDB

You may have heard about the upstart MySQL database MariaDB Getting Started with MariaDB, a branch of MySQL created in the wake of Oracle’s purchase of Sun Microsystems. You’ll find many great reasons to consider MariaDB, not least that MariaDB is led by the original author of MySQL, Monty Widenius. But there are reasons to stick with MySQL too for sometimes.

Step 1: Check that MySQL is installed

On Ubuntu 16.04/15.10/15.04:

1sudo systemctl status mysql

On Ubuntu 14.10 and previous versions:

1sudo service mysql status

Step 2: Uninstall MySQL

if you want to install MariaDB on your system first you have to uninstall existing MySQL. Follow these steps to uninstall completely existing MySQL from the server.

1-sudo systemctl stop mysql

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

Uninstall MySQL

1sudo apt-get autoremove

sudo apt-get autoclean

sudo rm -rf /var/lib/mysql/

sudo rm -rf /etc/mysql/

Step 3: Install MariaDB

When MySQL in uninstalled completely then run the following command to install MariaDB.

1sudo apt-get install mariadb-server

Step 4 (Final): Checking MariaDB is installed

1sudo systemctl status mysql

Successfully Uninstall MySQL from Ubuntu:

After following all the steps as stated in the article, you will be able to completely remove and uninstall MySQL from Ubuntu. If you are still facing any issues, feel free to comment on your queries below. We’d assist you ASAP.