While package management in Ubuntu, as in most Linux operating systems nowadays, makes it extremely easy to install, upgrade and delete a piece of software, some software is a bit more complex in nature and contains multiple configuration folders, etc. Show Table of Contents
One such complex software is MySQL Server. Uninstalling MySQL Server does not simply amount to running ‘apt purge‘ as is done usually. There are few small steps you can follow to completely uninstall MySQL Server from your Ubuntu machines. They are as follows: Backup All MySQL DatabasesIf you do not have any database created in MySQL, you can skip this step. If you have, before you remove MySQL Server from the system, make sure you take a backup of all your databases, so that when you reinstall it on another system or want to use the database on an existing server, you can simply restore them. Learn how to backup databases in MySQL here – How to Backup All MySQL Databases from Command-Line. Remove MySQL Server in UbuntuThe Ubuntu packages for MySQL Server start with ‘mysql-server’ and you can use ‘apt purge‘ to remove all these packages. $ sudo apt purge mysql-server*Remove MySQL Server in Ubuntu As you can see, it has removed 3 packages that contain files for the server. The reason we use ‘purge‘ instead of ‘remove‘ is that the former removes the configuration files for the program as well, whereas the latter only removes the program binaries. Remove MySQL Database Files and LogsThe command ‘apt purge‘ does remove the binaries and the configuration files, however, there are some more MySQL configuration files and the database files which are not touched by any package manager. The configuration files are present in /etc/mysql and the security keys and other related files are stored in /var/lib/mysql. $ ls /etc/mysql $ sudo ls /var/lib/mysqlMySQL Configuration Files Thus, these MySQL configuration files and database files need to be deleted manually. $ sudo rm -r /etc/mysql /var/lib/mysql If you have enabled logging for MySQL, make sure you delete the log files as well. $ sudo rm -r /var/log/mysql Remove Non-Required PackagesAlong with the MySQL Server packages installed by the package manager, there are some packages that are also installed as dependencies for the server. These are no longer required by the system, as the main package itself has been purged. They are also known as ‘Orphaned Packages’. Run the following apt command to remove such packages. $ sudo apt autoremoveRemove Packages Installed Automatically Note that this will remove ALL orphaned packages, not only the ones orphaned by the purging of the MySQL Server. You can see in the output that MySQL Client packages are also being removed, as they are now useless without the server package. ConclusionWe learned how to completely uninstall MySQL Server in Ubuntu in a few easy steps. Database deletions, upgrades, and installations should be handled with the utmost care, and data should be backed up from time to time, so as to prevent data-related disasters on a personal level or on an organizational level. Thanks for reading and let us know your thoughts in the comments below! I installed MySQL using How can I do that? asked Aug 6, 2012 at 8:44 I assume that you don't need MySQL anymore and you have already taken backup of your important databases. I suggest you to take backup of your important MySQL databases. Note: Your all mysql data will be lost. First make sure that MySQL service is stopped.
Remove MySQL related all packages completely.
Remove MySQL configuration and data. If you have changed database location in your MySQL configuration, you need to replace
(Optional) Remove unnecessary packages.
(Optional) Remove apt cache.
answered Aug 6, 2012 at 8:49 KK PatelKK Patel 17.7k13 gold badges56 silver badges78 bronze badges 14 all the above solutions are correct but I would try with sudo apt-get remove --purge mysql* sudo apt-get autoremove sudo apt-get autoclean This will uninstall all mysql related packages. Avinash Raj 74.3k52 gold badges209 silver badges250 bronze badges answered May 13, 2014 at 14:08 NaveenNaveen 1,0311 gold badge7 silver badges2 bronze badges 10 This will remove mysql 5.6 from ubuntu 15.04
answered May 3, 2015 at 18:34 VaskoVasko 4114 silver badges4 bronze badges 3 First you need to stop your mysql server from service.
Then You can use purge command to uninstall
Note: the above based on your package list. I have installed both server and client. This will for your convineient answered Feb 25, 2016 at 6:47 1 I don't use Ubuntu much but what I think you should try is what I did. I first typed this in command line : then followed with this below : and finally typed this : I found that it was removed. VedVals 3,2419 gold badges28 silver badges46 bronze badges answered Dec 4, 2012 at 14:54 TaretoTareto 511 silver badge1 bronze badge Completly uninstall mysql:
Based on this answer and many others... answered Jul 25, 2017 at 10:16 simhumilecosimhumileco 6411 gold badge10 silver badges16 bronze badges I forgot the MySQL root password and needed to reset. I tried this, but it didn't work, because it kept saying "can't write logs" or something similar. My solution was to completely remove MySQL from Ubuntu 13.10 and fresh installation.
I had to run the last command because Ubuntu sometimes keeps some libs even you try to purge them all. Now, I use this command to install MySQL server and client:
answered Feb 24, 2014 at 14:01 TennomTennom 3291 silver badge5 bronze badges When I tried Purged mysql5 with:
Then for cleaning up:
simhumileco 6411 gold badge10 silver badges16 bronze badges answered Aug 8, 2016 at 17:37 Try this, It will fully wipeout out every single file of MySQL from your system:
answered Mar 27, 2019 at 6:31 Not the answer you're looking for? Browse other questions tagged mysql software-uninstall or ask your own question. |