HowTo: Uninstall MySQL Server in Ubuntu Linux

I‘m a new Ubuntu Linux user and my cloud hosting company installed MySQL server by default. I need to remove it and delete it from my server as I have no use of MySQL server. How can I uninstall MySQL on a Ubuntu based systems?

Typically following Mysql packages are installed on the Debian or Ubuntu Linux systems:[donotprint]
Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsUbuntu/Debian
Time2m
[/donotprint]

ADVERTISEMENTS

  1. mysql-client – The latest version of MySQL database client.
  2. mysql-server – The latest version of MySQL database server.
  3. mysql-common – MySQL database common files.

How do I uninstall Mysql server?

Just use the apt-get command as follows remove both MySQL server and client in Ubuntu Linux:

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

Sample outputs (pay attention to package names):

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.2.0-31-virtual linux-headers-3.2.0-31
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  libdbd-mysql-perl* libmysqlclient18* mysql-client* mysql-client-5.5* mysql-common* mysql-server*
  mysql-server-5.5*
0 upgraded, 0 newly installed, 7 to remove and 0 not upgraded.
After this operation, 67.5 MB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 105097 files and directories currently installed.)
Removing mysql-server ...
Removing mysql-server-5.5 ...
mysql stop/waiting
Purging configuration files for mysql-server-5.5 ...
Removing mysql-client ...
Removing mysql-client-5.5 ...
Removing libdbd-mysql-perl ...
Removing libmysqlclient18 ...
Purging configuration files for libmysqlclient18 ...
Removing mysql-common ...
Purging configuration files for mysql-common ...
dpkg: warning: while removing mysql-common, directory '/etc/mysql' not empty so not removed.
Processing triggers for ureadahead ...
Processing triggers for man-db ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

Delete /etc/mysql/ directory using rm command:
$ sudo rm -rf /etc/mysql/

Understanding apt-get command options

  • --purge : Remove given packages and config files.
  • remove : Uninstall packages.
  • autoremove : Force to remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.
See also
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
8 comments… add one
  • Sebastian Mar 23, 2014 @ 10:30

    Isn’t ‘sudo apt-get purge mysql-client mysql-server mysql-common’ the same?

    • Leaman Mar 24, 2014 @ 2:34

      Yes, but this older syntax will work for all versions of Ubuntu and Debian. It’s slightly wordier, but if someone who has an older version of a Debian-based distribution on their hosted server will probably appreciate that the syntax works for them if they come across this article.

  • Mustafa Mar 23, 2014 @ 11:22

    Same

  • Rahul Yadav Apr 14, 2014 @ 4:43

    hye every one .i m Rahul I want install dontnet software in linux machine which tool should be use for install software.

  • Frank A Dec 26, 2015 @ 22:42

    Thanks for writing up a very useful article.:)

  • sachin May 24, 2016 @ 6:55

    I followed the above procedure but when I want to install fresh mysql then its showed the mysql is already in latest version

  • Oleg Tortajada Jul 29, 2016 @ 10:17

    Funciona bien la instalación ya que despues he podido volver a instalar mysql-server

    a pesar de que estos comandos de comprobación de paquetes me dan positivos
    –> apt-cache search mysql-server
    –> dpkg -l | grel mysql-server

  • danar Feb 18, 2017 @ 1:09

    it works!! Thanks

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.