How to remove MySQL package completely on Ubuntu 16.04

How to remove Mysql package completely on Ubuntu 16.04

MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. This tutorial will explain on how to remove mysql packages completely on Ubuntu 16.04.

 

Installation procedure

To start the installation procedure, first check the version of mysql by logging mysql.

root@linuxhelp1:~# mysql –u root –p
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 7
Server version: 5.7.17-0ubuntu0.16.04.2 (Ubuntu)
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> q

To remove the MySQL packages fully from the target system execute the following command. 

root@linuxhelp1:~# apt-get remove --purge mysql-server mysql-common
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libaio1 libevent-core-2.0-5 mysql-client-core-5.7 mysql-server-core-5.7
.
.
.
Purging configuration files for mysql-common (5.7.17-0ubuntu0.16.04.2) ...
dpkg: warning: while removing mysql-common, directory '/etc/mysql' not empty so not removed
Processing triggers for man-db (2.7.5-1) ...

Now remove the configuration directory and data directory by running the remove command. 

root@linuxhelp1:~#  rm -rf /etc/mysql /var/lib/mysql

Clean up unused dependencies using autoremove command. 

root@linuxhelp1:~# apt-get autoremove
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following packages will be REMOVED:
  libaio1 libevent-core-2.0-5 mysql-client-core-5.7 mysql-server-core-5.7
0 upgraded, 0 newly installed, 4 to remove and 469 not upgraded.
.
.
.
Removing libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...

To clear all local repository in the target system use autoclean command.

root@linuxhelp1:~# apt-get autoclean
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Del thunderbird-locale-es 1:45.5.1+build1-0ubuntu0.16.04.1 [728 kB]
Del thunderbird-locale-fr 1:45.5.1+build1-0ubuntu0.16.04.1 [427 kB]
.
.
.
Del thunderbird-locale-en-us 1:45.5.1+build1-0ubuntu0.16.04.1 [9,510 B]
Del libreoffice-pdfimport 1:5.1.4-0ubuntu1 [182 kB]
Del libreoffice-gnome 1:5.1.4-0ubuntu1 [60.5 kB]

Now remove all mysql related configuration files using purge command as follows. 

root@linuxhelp1:~# apt-get purge mysql*
Reading package lists... Done
Building dependency tree      
Reading state information... Done
Note, selecting 'mysqltcl' for glob 'mysql*'
.
.
.
Package 'mysql-testsuite' is not installed, so not removed
Package 'mysql-testsuite-5.7' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 469 not upgraded.

Wasn't that an easy configuration procedure? This procedure will ensure the complete removal of MySQL from the target system. 


Thank you! for using Linux Help.

You find this tutorial helpful? Share with your friends to keep it alive.
For more help topics browse our website www.linuxhelp.com
Be the first to comment, we value your suggestions. For further queries please comment below.

Tags: MySQL Ubuntu
user image Author :  Landon
user image
prakashvaghela 14-07-2018 at 19:08
Good Step by step Explaination :)
user image
jiweili 03-08-2018 at 13:30
Thank you for your blog,this is help me a lot.
user image
parthiban 28-08-2018 at 11:02
Thanks for your Feedback and keep in touch for further tutorials
user image
manojkumar 19-09-2018 at 22:58
Do Not use these steps. These steps remove everything that has been installed in current session. You will loose all installations or updates done in current session.