How do you uninstall MySQL from Mac OS X?
Asked Answered
W

16

229

I accidentally installed the PowerPC version of MySQL on my Intel Mac in Snow Leopard, and it installed without a problem but of course doesn't run properly. I just didn't pay enough attention. Now when I try to install the correct x86 version it says that it can't install because a newer version is already installed. A Google query led me to perform these actions/delete these files to uninstall it:

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/MySQL*
rm -rf ~/Library/PreferencePanes/MySQL*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*

And finally removed the line MYSQLCOM=-YES- from /etc/hostconfig

They haven't seemed to help at all. I am still receiving the same message about there being a newer version. I tried installing an even newer version (the current Beta) and it also gave me the same message about a newer version already being installed. I can't uninstall it from the Prefs Pane because I never installed the PrefPane also.

Woodruff answered 17/9, 2009 at 2:26 Comment(2)
sudo rm -rf lines with wildcards are a little irresponsible. Especially when you cast the net widely enough to delete anything starting with the letters "My" -- MySQL doesn't have exclusive ownership over the word "My" in its title.Feil
I'd also suggest backing up /usr/local/mysql/data first -- many people might not realize that that's where mysql keeps its data on mac.Amorette
M
236

Try running also

sudo rm -rf /var/db/receipts/com.mysql.*
Mullein answered 19/9, 2009 at 4:40 Comment(1)
also sudo rm -rf /Library/StartupItems/MySQLCOM if it existsExpire
D
39

I also had entries in:

/Library/Receipts/InstallHistory.plist

that i had to delete.

Daffie answered 29/4, 2011 at 20:56 Comment(1)
What kind of entries were these? Hopefully it was just in the older versions but I don't see anything named mysql in there.Contrive
D
36

If you installed mysql through brew then we can use command to uninstall mysql.

$ brew uninstall mysql

Uninstalling /usr/local/Cellar/mysql/5.6.19...

This worked for me.

Douai answered 8/7, 2014 at 15:26 Comment(3)
I wish... I'm removing my dmg version from 10.8 so I can install the brew version! :-)Amplify
Also remove "export PATH="/usr/local/opt/[email protected]/bin:$PATH"" from ~/.zshrc or ~/.bash_profile or ~/.bashrc.Saleratus
worked for me for the default MySQL 8.0.22 for MojaveAustraloid
C
21
ps -ax | grep mysql

*stop and kill any MySQL processes

brew remove mysql
brew cleanup

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/MySql*

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

edit /etc/hostconfig and remove the line MYSQLCOM=-YES-

rm -rf ~/Library/PreferencePanes/My*    
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*

*restart your computer just to ensure any MySQL processes are killed try to run mysql, it shouldn't work

Chandachandal answered 27/9, 2016 at 17:6 Comment(2)
I had installed mysql 5.6 using brew. Doing brew remove mysql was giving me error: "Error: No such keg: /usr/local/Cellar/mysql". So I had to do brew uninstall [email protected]. Also, I had to remove "export PATH="/usr/local/opt/[email protected]/bin:$PATH"" from bash profile (~/.zshrc for my case)Saleratus
I . runn brew remove mysql , however I got the error "No available formula or cask with the name "mysql".Nubile
H
15

OS version: 10.14.6 MYSQL version: 8.0.14

Goto System preferences -> MYSQLenter image description here

Stop MySQL server

enter image description here

One option will be shown here to uninstall MYSQL 8 after stopping Mysql server

Hughs answered 7/6, 2020 at 2:48 Comment(0)
U
12

Aside from the long list of remove commands in your question, which seems quite comprehensive in my recent experience of exactly this issue, I found mysql.sock running in /private/var and removed that. I used

find / -name mysql -print 2> /dev/null

...to find anything that looked like a mysql directory or file and removed most of what came up (aside from Perl/Python access modules). You may also need to check that the daemon is not still running using Activity Monitor (or at the command line using ps -A). I found that mysqld was still running even after deleting the files.

Umberto answered 19/9, 2009 at 4:37 Comment(1)
You can (and in this case, probably should) use -iname if your find supports it to perform a case-insensitive searchEnunciation
K
4

I also had a config file at /etc/my.cnf that I needed to delete on my Mac OS X Snow Leopard install

Karankaras answered 11/2, 2011 at 17:7 Comment(0)
U
4

It might be overkill but your MySQL command history can also be wiped from:

~/.mysql_history
Utterance answered 16/11, 2012 at 19:58 Comment(0)
C
3

You need to identify where MySQL was installed to before attempting to delete it.

I always use the Hivelogic guide to installing under Mac OS X which builds MySQL from source. When setting up the build you can specify a directory under which to install MySQL with the --prefix parameter. You should make sure the directory does not exist and attempt to install from source.

./configure --prefix=/usr/local/mysql --with-extra-charsets=complex \
--enable-thread-safe-client --enable-local-infile --enable-shared \
--with-plugins=innobase
Candida answered 17/9, 2009 at 2:40 Comment(1)
Old answer, I know, but it came up in a review task. Maybe you should add how to identify where mysql was installed, not just how to install it. As it is, it doesn't really answer the question.Zehe
A
3

You should also check /var/db/receipts and remove all entries that contain com.mysql.*

Using sudo rm -rf /var/db/receipts/com.mysql.* didn't work for me. I had to go into var/db/receipts and delete each one seperately.

Adamsun answered 26/8, 2015 at 19:5 Comment(0)
E
1

I also found

/Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

after using all of the other answers here to uninstall MySQL Community Server 8.0.15 from OS X 10.10.

Ezmeralda answered 21/2, 2019 at 6:0 Comment(0)
H
0

For me, I had installed MariaDB years ago using homebrew. Correct uninstall procedure was: brew uninstall mariadb.

Hypnoanalysis answered 16/7, 2016 at 6:17 Comment(0)
B
0

This did the job for me:

brew uninstall mysql
Burgee answered 9/3, 2021 at 1:28 Comment(0)
Y
0
brew uninstall --force mysql@<version_no>

exmample

brew uninstall --force [email protected]

to get version check cd /usr/local/Cellar

Yovonnda answered 23/12, 2022 at 20:44 Comment(0)
S
-2

Remove MySQL completely

Open the Terminal

Use mysqldump to backup your databases

Check for MySQL processes with:

ps -ax | grep mysql

Stop and kill any MySQL processes

Analyze MySQL on HomeBrew:

brew remove mysql
brew cleanup

Remove files:

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*

Unload previous MySQL Auto-Login:

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

Remove previous MySQL Configuration:

subl /etc/hostconfig` 
# Remove the line MYSQLCOM=-YES-

Remove previous MySQL Preferences:

rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*

Restart your computer just to ensure any MySQL processes are killed

Try to run mysql, it shouldn't work

Sutphin answered 15/11, 2018 at 11:39 Comment(1)
copied from gist.github.com/vitorbritto/0555879fe4414d18569dDorotheadorothee
C
-11

sudo find / | grep -i mysql

This worked like a charm for me. Just went through the list and ensured that anything MySQL related was deleted.

Coccyx answered 19/1, 2010 at 15:16 Comment(3)
This ended up being very bad for me, as it found things like the MySQL images that Coda 2 used, as well as some files in Adobe Bridge.Tempi
faster: sudo find / -iname "*mysql*"Saxen
This is very bad suggestion. I have ruined my system. It has removed any file that had mysql in their name. It has even corrupted sequel pro and other softwares. Now even though reinstall mysql but I get errors when I try to connect with sequel pro. Please report this answer and have it removed before many more people ruin their computer. And please suggest me what should I do now?Sobriety

© 2022 - 2024 — McMap. All rights reserved.