MySQL MariaDB

How to Uninstall MySQL From Terminal?

Sometimes developers and database administrators might face difficulties in managing disk space due to the clutter of software, databases, and management systems, such as MySQL. Moreover, their relevant projects are no longer needed. It is ideal to uninstall MySQL to free up disk space in such a situation.

This guide will discuss how to uninstall MySQL from the Linux terminal.

How to Uninstall MySQL From Terminal?

In order to uninstall MySQL from the terminal, first manually stop the MySQL service that is running on the system by typing:

sudo systemctl stop mysql

The error-free output means the service of MySQL is stopped successfully:

Remove the MySQL packages as well as its dependencies from the system by following this command:

sudo apt autoremove mysql-* --purge -y

It will consume some time to select all the packages that should be removed along with MySQL package:

Wait until the uninstallation process is running:

Once the process, run the following command to clear the repositories that are no longer needed:

sudo apt autoclean

Wait for this command to complete its execution:

To confirm whether MySQL is completely uninstalled from the system or not, run this command:

mysql --version

This command displays the version number of installed MySQL if this command return “Command ‘mysql’ not found” message it means MySQL is no longer available on your system:

MySQL has been successfully uninstalled from the system using the terminal.

Conclusion

To uninstall MySQL from the terminal, first, stop the MySQL service and run the “sudo apt autoremove mysql-* –purge -y” command to remove MySQL along with its dependencies. Once the packages are uninstalled, run the “sudo apt autoclean” to the repositories that are no longer required. This guide demonstrated how to uninstall MySQL from the terminal.

About the author

Abdul Mannan

I am curious about technology and writing and exploring it is my passion. I am interested in learning new skills and improving my knowledge and I hold a bachelor's degree in computer science.