Completely Remove MySQL from Ubuntu

To completely remove MySQL from an Ubuntu system, follow these steps:

1. Stop MySQL Service:

First, stop the MySQL service if it’s running:

   sudo systemctl stop mysql

2. Uninstall MySQL Packages:

Remove the MySQL packages using the following commands:

   sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*

3. Remove MySQL Configuration and Data Files:

After purging MySQL packages, some configuration and data files might still remain on your system. You can remove them with:

   sudo rm -rf /etc/mysql /var/lib/mysql

4. Remove MySQL Dependencies and Unused Packages:

Clean up any dependencies that were installed with MySQL and are no longer needed:

   sudo apt-get autoremove
   sudo apt-get autoclean

5. Remove MySQL User and Group:

You can also remove the MySQL user and group created during installation (optional):

   sudo deluser mysql
   sudo delgroup mysql

6. Verify MySQL Removal:

To ensure that MySQL is completely removed, you can check if there are any MySQL packages left:

   dpkg -l | grep mysql

If the command returns no output, MySQL has been successfully removed from your system.

These steps will completely remove MySQL from your Ubuntu system, including all associated configuration files and databases.

Leave a Reply

Your email address will not be published. Required fields are marked *