Completely remove mysql and its data from Ubuntu OS

mahabub.devs3
Mahabubur Rahman
Published on Dec, 06 2024 1 min read 0 comments
image

To completely remove MySQL and its data from your Ubuntu system, follow these steps:

1. Stop the MySQL Service: Ensure that the MySQL service is stopped:

sudo systemctl stop mysql

2. Uninstall MySQL Packages: Remove all MySQL-related packages from your system:

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

3. Delete MySQL Data and Log Files: Delete the MySQL data directory and log files:

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

4. Remove MySQL User and Group (Optional): If you no longer need the MySQL user and group, you can remove them:

sudo deluser mysql
sudo delgroup mysql

5. Update the Package Database: Update the package database to ensure that all changes are recognized by the system:

sudo apt-get update

6. Remove Unused Dependencies: Clean up any unused dependencies:

sudo apt-get autoremove
sudo apt-get autoclean

7. Verify Removal: Confirm that MySQL has been completely removed:

dpkg -l | grep mysql

By following these steps, you should be able to completely remove MySQL and its associated data from your Ubuntu system. If you encounter any issues or need further assistance, feel free to ask!

0 Comments