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 &ndash u root &ndash 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.

Tag : MySQL Ubuntu
Comment
parthiban
Aug 27 2018
Thanks for your Feedback and keep in touch for further tutorials
jiweili
Aug 02 2018
Thank you for your blog,this is help me a lot.
prakashvaghela
Jul 13 2018
Good Step by step Explaination :)
Add a comment
FAQ
Q
What are the features of a SQL?
A
SQL Developer supports the following core features when migrating from Microsoft SQL Server: ... Parses and transforms T-SQL stored procedures, functions, triggers, and views to Oracle PL/SQL. Provides advanced customization capabilities such as the ability to change data type mappings, delete and rename objects.
Q
Is MySQL is a programming language?
A
SQL stands for Structured Query Language, and it is a programming language designed for querying data from a database. MySQL is a relational database management system, which is a completely different thing.
Q
What is the MySQL service?
A
MySQL server is a SQL compliant server, in other words, it is a relational model database server. It is very popular because it is free. It was developed by Sun and moved to Oracle when Oracle acquired Sun. Oracle continued improving it. The latest version is 5.7.
Q
Is MySQL the same as SQL Server?
A
While developing software applications, programmers use relational database management system (RDBMS) to create, read, update and delete back-end data. ... Both MySQL and MS SQL Server are widely used enterprise database systems. MySQL is an open source RDBMS, whereas SQL Server is a Microsoft product.
Q
how can I check it is permanently removed or not ?
A
check the package still available using dpkg -l | grep mysql if yes, remove completely using dpkg --purge & check