I installed MySQL using sudo apt-get
. Now I need to remove it from my system.
How can I do that?
I installed MySQL using sudo apt-get
. Now I need to remove it from my system.
How can I do that?
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.
sudo systemctl stop mysql
Remove MySQL related all packages completely.
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
Remove MySQL configuration and data. If you have changed database location in your MySQL configuration, you need to replace /var/lib/mysql
according to it.
sudo rm -rf /etc/mysql /var/lib/mysql
(Optional) Remove unnecessary packages.
sudo apt autoremove
(Optional) Remove apt cache.
sudo apt autoclean
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.
sudo apt-get remove --purge -s 'mysql*'
to be more specific.
– geerlingguy
May 23 '14 at 18:52
E: Unable to locate package mysql
. my installation seems to be a bit messed up. and it kind of frightening that i cant even re-install it.
– phil294
Aug 03 '16 at 20:17
*
at your own peril. bash
will expand all matching cases and remove them, even if they might be unrelated to mysql
.
–
Apr 29 '17 at 00:23
sudo apt-get autoremove
very misleading... it also uninstall some of installed applications
– Shift 'n Tab
Mar 06 '18 at 07:16
This will remove mysql 5.6 from ubuntu 15.04
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
First you need to stop your mysql server from service.
sudo service mysql stop
Then You can use purge command to uninstall
sudo apt-get purge mysql-server mysql-client
Note: the above based on your package list. I have installed both server and client. This will for your convineient
dpkg: unrecoverable fatal error, aborting: fork failed: Cannot allocate memory E: Sub-process /usr/bin/dpkg returned an error code (2)
Stopping MySQL, then running
sudo dpkg --configure -a
followed by
sudo apt-get remove --purge mysql*
worked for me.
sudo -i
service mysql stop
killall -KILL mysql mysqld_safe mysqld
apt-get --yes purge mysql*
apt-get --yes autoremove --purge
apt-get autoclean
deluser --remove-home mysql
delgroup mysql
rm -rf /etc/apparmor.d/abstractions/mysql /etc/apparmor.d/cache/usr.sbin.mysqld /etc/mysql /var/lib/mysql /var/log/mysql* /var/log/upstart/mysql.log* /var/run/mysqld ~/.mysql_history
updatedb
Based on this answer and many others...
I don't use Ubuntu much but what I think you should try is what I did.
I first typed this in command line : sudo apt-get remove --purge mysql-server mysql-client mysql-common
,
then followed with this below : sudo apt-get autoremove
and finally typed this : sudo apt-get autoclean
.
I found that it was removed.
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.
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo rm -rf /var/lib/mysql
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:
sudo apt-get install mysql-client mysql-server
Try this, It will fully wipeout out every single file of MySQL from your system:
sudo service mysql stop #or mysqld
sudo killall -9 mysql
sudo killall -9 mysqld
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser -f mysql
sudo rm -rf /var/lib/mysql
sudo apt-get purge mysql-server-core-5.7
sudo apt-get purge mysql-client-core-5.7
sudo rm -rf /var/log/mysql
sudo rm -rf /etc/mysql
When I tried sudo apt-get purge mysql*
it didn't work.
Purged mysql5 with:
sudo apt-get purge mysql-*
Then for cleaning up:
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get install mysql-client-core-5.5
. But it shows :mysql-client-core-5.5 is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 97 not upgraded.
. Is that mean still mysql resides in my pc? – batman Aug 06 '12 at 09:35sudo dpkg --purge mysql-server mysql-client mysql-common
I get :dpkg: warning: there's no installed package matching mysql-server dpkg: warning: there's no installed package matching mysql-client dpkg: warning: there's no installed package matching mysql-common
. I'm bit confused now. Is thatmysql
have been removed or not? – batman Aug 06 '12 at 11:17xbmc
andxbmc-bin
as well? There are noxbmc
tables inmysql
when browsing withphpmyadmin
. – Redsandro Jan 16 '14 at 17:47rm -rf /var/log/mysql
– jlh Apr 08 '16 at 07:15sudo apt-get purge mysql* mariadb*
– Dejv Jun 14 '16 at 13:15sudo rm -rf /var/lib/mysql
will remove your databases in default location. DO a back up first, if you feel you may need your data later on! – Augusto Oct 10 '16 at 09:40sudo apt autoremove
. It deleted a lot of important stuff from my server! – Soheil Rahsaz Mar 02 '22 at 14:21