Not able to uninstall MySQL with apt-get
Solution 1
Assuming you need to completely remove mysql related packages and its configs, please try below;
sudo apt-get remove --purge mysql* # will remove all relating packages and its config
sudo apt-get autoremove
sudo apt-get autoclean
And above command will completely remove all mysql related packages.
Hope it helps!!
Solution 2
If you installed MYSql from .tar.gz file, you can't able to uninstall it through Ubuntu's native package management system (apt-get
).
Find the uninstall.sh
script inside the extracted directory and run it to completely remove all the files related to MYSQL.
Solution 3
The following will uninstall everything that contain mysql
.
apt-get remove --purge mysql*.*
apt-get autoremove
apt-get autoclean
Then run again the following to check any remaining packages.
dpkg --get-selections | grep -v deinstall | grep "mysql"
In my case, I only see mysql-common
.
Reinstall and everything should work.
Related videos on Youtube
faizal
Updated on September 18, 2022Comments
-
faizal over 1 year
I had downloaded the generic Linux 64 bit MySQL 5.6.17 TAR archive from http://dev.mysql.com/downloads/mysql/ and installed on my 64 bit Ubuntu 14.04, following the instructions at http://dev.mysql.com/doc/refman/5.6/en/binary-installation.html.
I am having some problems with the server, so i want to uninstall and do a fresh installation. But if i try the usual
apt-get remove mysql-server
(as per How do I uninstall Mysql?), i get :Package 'mysql-server' is not installed, so not removed
I am guessing this is because i did not use apt-get to install in the first place. I had used
scripts/mysql_install_db
as per the instructions.So is there some other way to uninstall MySQL server or is it ok to just delete the installation folder?
Edit
$ dpkg --get-selections | grep -v deinstall | grep "mysql"
gives the below result :
libdbd-mysql-perl install libmysqlclient18:amd64 install mysql-client install mysql-client-5.5 install mysql-client-core-5.5 install mysql-common install mysql-workbench-community install
-
AzkerM almost 10 yearsHi! I'm not too sure whether this will help but can you please try,
dpkg --get-selections | grep -v deinstall | grep "mysql"
and post the output if you see any packages or matches. This command will output packages relating to the word mysql while printing all the installed packages. :) -
Avinash Raj almost 10 years
sudo apt-get remove mysql*
-
AzkerM almost 10 yearsAvinashRaj Exactly the same command that I was trying to comment on. @faizal please look into my answer
-
-
faizal almost 10 yearsDoes such a script exist? I could not find it in my installation folder(find $MYSQL_HOME -name 'uninstall.sh')
-
Avinash Raj almost 10 yearsMost of the .tar.gz files comes with an un-installation script. I don't know about MYSQL.
-
faizal almost 10 yearsThanks AzkerM. But i am really nervous about doing this now. I have managed to make the existing MySQL work for now after a lot of experimenting. If i do face more problems, i will surely give this a try.
-
AzkerM almost 10 yearsIt is always a best practice to make a use of official repo's available within Ubuntu unless you've no other choice. Anyhow, its your call & in any event we're always happy to help. :)
-
faizal almost 10 yearsI did not use the Ubuntu repo because it was downloading MySQL 5.5, while 5.6 was available for download from the mysql site. I have realized now that was an error of judgement :(
-
AzkerM almost 10 yearsWell there is a PPA for MySQL 5.6 given with an explanation on Launchpad which you should have tried. I also see certain bugs reported relating to this. Anyhow, there is no victory without pain. If your package is working and issues sorted, good to go though.
-
ipcjs about 7 yearsyou right. The script is
/root/oneinstack/uninstall.sh
on my server. -
Claus about 7 yearsSuperb. Works like charm.
-
Lajos Mészáros over 2 yearsA little side note is that I had to go to / to execute the remove --purge command. Standing in my home directory resulted in apt-get not being able to locate packages