Uninstall mysql from ubuntu
Table of Contents
Introduction
This tutorial provides a step-by-step guide on how to uninstall MySQL from an Ubuntu system. Whether you're troubleshooting issues, upgrading to a different database management system, or simply no longer need MySQL, this guide will walk you through the uninstallation process.
Step 1: Update Package List
Before uninstalling MySQL, it’s a good practice to update your package list. This ensures you are working with the latest package information.
- Open your terminal.
- Run the following command:
sudo apt update
Step 2: Stop MySQL Service
You need to stop the MySQL service before proceeding with the uninstallation.
- Execute the following command in the terminal:
sudo systemctl stop mysql
Step 3: Uninstall MySQL
Now you can proceed with the uninstallation of MySQL.
- Use the following command to remove MySQL and its associated packages:
sudo apt remove mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
Step 4: Remove MySQL Configuration Files
To ensure a complete uninstallation, you should also remove configuration files that might still be present on your system.
- Run the following command:
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
Step 5: Delete MySQL Data Directory
If you want to remove all MySQL databases and data, you will need to delete the MySQL data directory.
- Execute this command:
sudo rm -rf /etc/mysql /var/lib/mysql
Step 6: Clean Up Residual Packages
After uninstallation, it's a good idea to clean up any residual packages that are no longer required.
- Run this command:
sudo apt autoremove
Conclusion
You have successfully uninstalled MySQL from your Ubuntu system. Remember to check for any remaining files or configurations if you plan to reinstall MySQL later. If you need a different database management system, consider exploring alternatives like PostgreSQL or MariaDB for your future projects.