Uninstall MySQL in Ubuntu 20.04 | 22.04


If you have MySQL installed in your Linux ubuntu apache system and you want to remove mysql from your linux ubuntu system due to any reason. Or Uninstalling MySQL from your Ubuntu 22.04 system can be necessary when you want to switch to a different database management system or perform a clean reinstallation. So through this tutorial, we will show you how to completely uninstall mysql in linux Ubuntu 20.04 | 22.04.

How to Uninstall MySQL in Ubuntu 20.04 | 22.04 Terminal

Steps to completely uninstall mysql in linux ubuntu 20.04 | 22.04 using terminal or command line:

  • Step 1: Stop MySQL Service
  • Step 2: Uninstall MySQL & Packages Ubuntu
  • Step 3: Remove MySQL Configuration Files
  • Step 4: Remove MySQL User and Group
  • Step 5: Verify Uninstallation
  • Step 6: Clean Up

Step 1: Stop MySQL Service

Open a terminal window by pressing Ctrl + Alt + T or searching for “Terminal” in the applications menu. Then, stop the MySQL service using the following command:

sudo systemctl stop mysql

Step 2: Uninstall MySQL & Packages Ubuntu

Ubuntu 20.4|22.04 uses the APT package manager. To uninstall MySQL and its related packages, use the following commands:

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

Step 3: Remove MySQL Configuration Files

After removing the packages, some configuration files may still remain. Use the following command to remove them:

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

This will delete the MySQL configuration files and data directories.

Step 4: Remove MySQL User and Group

You can remove the MySQL user and group by running the following commands:

sudo deluser mysql
sudo delgroup mysql

Step 5: Verify Uninstallation

To verify that MySQL has been successfully uninstalled, try accessing the MySQL prompt. You should receive an error message indicating that the MySQL client isn’t installed:

mysql -u root -p

Step 6: Clean Up

After completing the uninstallation, it’s a good idea to update the APT package cache and upgrade any remaining packages:

sudo apt-get update
sudo apt-get upgrade

Conclusion

Congratulations, you have successfully uninstalled MySQL from your Ubuntu 22.04 system! If you no longer need MySQL, your system should now be clean of all MySQL-related components.

Recommended Tutorials

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?