You are currently viewing How to uninstall Mysql database

How to uninstall Mysql database

You may want to uninstall MySQL database service from your server/machine. When this happens, you need skills to work it out. See the procedure outlined below:

How to Uninstall MYSQL Database from a Linux system

1. Stop MySQL Server:

Ensure that the MySQL server is stopped before uninstalling:

sudo systemctl stop mysql

2. Remove MySQL Packages:

Remove the MySQL packages using apt-get:

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

This command will remove the MySQL server, client, common packages, and configuration files. Respond to the prompts as needed.

3. Remove MySQL Configuration Files:

Remove any remaining MySQL configuration files and directories:

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

4. Remove MySQL User and Group:

The MySQL installation creates a system user and group. Remove these if they exist:

sudo deluser mysql
sudo delgroup mysql

5. Clean Up

Though not a must, it is recommended to Clean up any remaining dependencies or unnecessary packages.

sudo apt-get autoremove
sudo apt-get autoclean

6. Remove MySQL Directory

If there are any remaining MySQL directories, remove them

sudo rm -rf /var/log/mysql

At this point, all MySQL files could be removed. You may however need to do further checks as outlined below.

7. Check for Any Remaining MySQL Packages

To ensure that all MySQL packages are removed, run the following command. In case any files associated with MySQL, remove them.

dpkg -l | grep mysql

8. Purge MySQL Configuration Files

Purge any remaining MySQL configuration files. See the command.

sudo dpkg --purge mysql-common

9. Check MySQL Service

Verify that MySQL service is no longer present. Run the command below:

systemctl list-units --type=service | grep mysql

Finally, restart your system if needed.

sudo reboot

The above steps on how to uninstall MySQL database from a Linux system ensure that all MySQL-related files and services are removed. In case of any queries or challenges, drop a comment and we will assist further.

Make a donation to support us




For web development services, SEO services, Digital marketing strategies, website set up services, web hosting and domain registration; contact Dynamic Technologies.


Related content: