Monday, February 4, 2019

How to remove MySQL completely in Ubuntu-16.04 ?

In this post we will discuss how to delete mysql server.

If you want to backup the database before removing MySQL service, you can refer the post

How to take MySQL dump using the command utility "mysqldump"

This post assumes you have running instance of mysql server which you want to remove or the corrupted one which you want to get rid of...

In the former case let us confirm first that the server is not running...

use the following command to check the server is running or not
> service mysql status or systemctl status mysql
the response would let you know whether the server is running or not

if the server is running then shut it down first as follows...
> sudo service mysql stop
use "service mysql status" to check the server has come to a stop.

Now we are going to perform the action intented... which is removing the mysql service

execute the following commands in order as they are mentioned at the terminal
> sudo apt-get remove --purge mysql*
> sudo apt-get purge mysql*
> sudo apt-get autoremove
> sudo apt-get autoclean
> sudo apt-get remove dbconfig-mysql

Deleteing the mysql directory in /etc and /var/lib
> sudo rm -rf /etc/mysql
> sudo rm -rf /var/lib/mysql

If you want to install MySQL Server again, you can check my post

MySQL Server Installation in Ubuntu - 18.10

Well that is it, please post your comments if you encounter any issue while removing the instance thanks.

No comments:

Post a Comment

How to change the root password in linux when it is forgotten/to change

This blog is all about changing the root password of the Linux system when it is forgotten or to reset the password...   Let's get it ...