If you find yourself needing to uninstall MySQL, it can be tricky sometimes to know if you’ve uninstalled it completely. Whether your running MySQL on Linux or Windows, just follow these instructions to uninstall MySQL and its associated data completely.
How to Uninstall MySQL in Linux
Need to uninstall MySQL from Linux? You can uninstall MySQL using your Linux distributions package manager and the remove command. To do so, just follow these 2 easy steps:
- First, depending on which distribution of Linux you’re running, you’ll need to use one of the following package manager commands:
- For CentOS and RedHat users:
sudo yum remove mysql mysql-server
- For Ubuntu and Debian users:
sudo apt remove mysql mysql-server
- For Fedora users (as well as for many subsidiary distributions):
sudo dnf remove mysql mysql-server
- For CentOS and RedHat users:
- Now that MySQL has been removed, the next step is to ensure that the existing data directory is deleted as well. By default, this can be found at /var/lib/mysql. You can choose to delete this directory entirely using the remove command, but it’s typically better to simply rename the old directory to something new. This way, the data remains, in case you ever need to access it in the future, but should you reinstall MySQL, it won’t check the newly renamed file and will instead create a new directory.
To rename the old MySQL directory use the mv command:
sudo mv /var/lib/mysql /var/lib/mysql_directory_backup
*Note: need a refresher on renaming in Linux? Check out this post from our Knowledge Base!
At this point, you’ve successfully uninstalled MySQL from your Linux server. If you’d like to reinstall MySQL, you can do so using your distribution’s package manager, replacing the “remove” commands used above with the install command instead:
- For CentOS and RedHat users:
sudo yum install mysql mysql-server
- For Ubuntu and Debian users:
sudo apt install mysql mysql-server
- For Fedora users (as well as for many subsidiary distributions): sudo dnf install mysql mysql-server
How to Uninstall MySQL in Windows
To completely remove MySQL from your Windows system, just follow these 3 steps:
- First, you’ll need to uninstall MySQL from your Windows’ Control Panel. Navigate to Control Panel -> Programs and Features -> MySQL. From there, click on the option to Uninstall.
- Once MySQL is uninstalled, to completely remove the program, you need to ensure its data directories are removed as well. *Note: you may want to create backups of these directories before deleting them.
- Open a terminal window (make sure you’re running it as Administrator), and stop, then delete the MySQL service using the following two commands:
Net stop MySQL
Sc delete MySQL
- Now, navigate to the Start menu, and type in Show hidden files and folders. Select the View tab and remove the following folders from your system:
C:\Program Files\MySQL
C:\Program Files (x86)\MySQL
C:\ProgramData\MySQL
Also check if a folder exists at the location: C:\Users\[YourUsername]\AppData\Roaming\MySSQL
If so, delete this folder as well.
- Open a terminal window (make sure you’re running it as Administrator), and stop, then delete the MySQL service using the following two commands:
- Once everything is uninstalled and your MySQL data directories have been deleted, simply restart your computer and confirm that the changes have taken place.
And there you have it! MySQL is uninstalled and its data directories are removed.
Popular Links
Looking for more information on MySQL? Search our Knowledge Base!
Interested in more articles about Databases? Navigate to our Categories page using the bar on the left or check out these popular articles:
- View the Contents of a Table in a SQL Server Database Using Enterprise Manager
- Create a MySQL Backup from Command Line – MySQL Import SQL File
- How to Install SQL Server 2012 Express on Windows Server 2012
Popular tags within this category include: MySQL, MSSQL, phpMyAdmin, PostgreSQL, and more.
Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.
The Hivelocity Difference
Seeking a better Dedicated Server solution? In the market for Private Cloud or Colocation services? Check out Hivelocity’s extensive list of products for great deals and offers.
With best-in-class customer service, affordable pricing, a wide-range of fully-customizable options, and a network like no other, Hivelocity is the hosting solution you’ve been waiting for.
Unsure which of our services is best for your particular needs? Call or live chat with one of our sales agents today and see the difference Hivelocity can make for you.