1. Home
  2. MySQL Tutorials
  3. Uninstall MySQL 5.7 on Ubuntu 16.04

Uninstall MySQL 5.7 on Ubuntu 16.04

Previous article we have covered How to Install MySQL 5.7 on Ubuntu 16.04. In this tutorial , We are going to cover How to Uninstall MySQL 5.7 on Ubuntu 16.04 LTS Step by Step or any Cloud Instance like Amazon EC2, Azure VM, Google Compute Engine,etc. with preinstalled MySQL 5.7 and Ubuntu 16.04.


  • Ubuntu 16.04 LTS System
  • SSH access with sudo privileges

First Uninstall MySQL package using below command.

sudo apt-get remove dbconfig-mysql

Sample Output:

The following packages will be REMOVED:

  mysql-apt-config* mysql-client* mysql-common* mysql-community-client* mysql-community-

server* mysql-router* mysql-router-community* mysql-server*


0 upgraded, 0 newly installed, 9 to remove and 133 not upgraded.

After this operation, 312 MB disk space will be freed.

Do you want to continue? [Y/n] y

(Reading database ... 218376 files and directories currently installed.)

Removing mysql-apt-config (0.8.15-1) ...

Purging configuration files for mysql-apt-config (0.8.15-1) ...

Removing mysql-server (5.7.29-1ubuntu16.04) ...

Removing mysql-community-server (5.7.29-1ubuntu16.04) ...

update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf 

(my.cnf) in auto mode

Purging configuration files for mysql-community-server (5.7.29-1ubuntu16.04) ...


sent invalidate(passwd) request, exiting

sent invalidate(group) request, exiting

sent invalidate(passwd) request, exiting

sent invalidate(group) request, exiting

Removing mysql-client (5.7.29-1ubuntu16.04) ...

Removing mysql-community-client (5.7.29-1ubuntu16.04) ...

Purging configuration files for mysql-community-client (5.7.29-1ubuntu16.04) ...

Removing mysql-common (5.7.29-1ubuntu16.04) ...

Purging configuration files for mysql-common (5.7.29-1ubuntu16.04) ...

update-alternatives: warning: alternative /etc/mysql/my.cnf.fallback (part of link group

 my.cnf) doesn't exist; removing from list of alternatives

update-alternatives: warning: /etc/alternatives/my.cnf is dangling; it will be updated

 with best choice

Removing mysql-router (8.0.18-1ubuntu16.04) ...

Removing mysql-router-community (8.0.18-1ubuntu16.04) ...

Purging configuration files for mysql-router-community (8.0.18-1ubuntu16.04) ...

dpkg: warning: while removing mysql-router-community, directory '/etc/mysqlrouter' not 

empty so not removed

Removing mysql-server-5.7 (5.7.29-0ubuntu0.16.04.1) ...

Purging configuration files for mysql-server-5.7 (5.7.29-0ubuntu0.16.04.1) ...

userdel: user 'mysql' does not exist

Processing triggers for man-db (2.7.5-1) ...

Processing triggers for libc-bin (2.23-0ubuntu10)

Remove the all files related to MySQL

sudo apt-get remove --purge mysql*

It asks to remove data directories, if you want to remove , Enter on Yes button.

remove mysql 5 data directories

Next it asks to remove all MySQL databases, if you want to remove, Enter on Yes button.

remove mysql 5 all databases

To remove undependent packages .

sudo apt-get autoremove

To clean local apt  pacakges.

sudo apt-get autoclean


Reading package lists... Done

Building dependency tree

Reading state information... Done

Del mysql-common 5.7.29-1ubuntu16.04 [76.2 kB]

Del mysql-community-client 5.7.29-1ubuntu16.04 [10.9 MB]

Del mysql-client 5.7.29-1ubuntu16.04 [72.7 kB]

Del mysql-community-server 5.7.29-1ubuntu16.04 [32.2 MB]

Del mysql-server 5.7.29-1ubuntu16.04 [72.6 kB]


In this article, We have covered, How to Uninstall MySQL 5.7 on Ubuntu 16.04 LTS Step by Step.

Uninstall MySQL 8 on Ubuntu 18.04/16.04 LTS


MySQL Official Documentation


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.