226

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.

Rick
  • 3,240
  • 2
  • 29
  • 53
Joseph Ravenwolfe
  • 6,480
  • 6
  • 31
  • 31
  • 35
    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. – Eric G Mar 12 '12 at 22:49
  • 6
    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. – Michael Scott Asato Cuthbert Aug 21 '14 at 21:17

16 Answers16

235

Try running also

sudo rm -rf /var/db/receipts/com.mysql.*
Sophie Alpert
  • 139,698
  • 36
  • 220
  • 238
38

I also had entries in:

/Library/Receipts/InstallHistory.plist

that i had to delete.

rm-rf
  • 1,313
  • 1
  • 15
  • 24
  • What kind of entries were these? Hopefully it was just in the older versions but I don't see anything named mysql in there. – Termato Feb 03 '16 at 22:27
34

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.

Joseph Ravenwolfe
  • 6,480
  • 6
  • 31
  • 31
bapu
  • 661
  • 6
  • 7
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

dantiston
  • 5,161
  • 2
  • 26
  • 30
Victor
  • 761
  • 8
  • 7
  • 1
    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 mysql@5.6`. Also, I had to remove "export PATH="/usr/local/opt/mysql@5.6/bin:$PATH"" from bash profile (~/.zshrc for my case) – Himanshu Tanwar Dec 06 '18 at 07:29
  • 1
    I . runn brew remove mysql , however I got the error "No available formula or cask with the name "mysql". – YuFeng Shen Apr 20 '21 at 13:39
14

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

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.

mblackwell8
  • 3,065
  • 3
  • 21
  • 23
  • 1
    You can (and in this case, probably should) use `-iname` if your `find` supports it to perform a case-insensitive search – damd Oct 13 '16 at 12:46
4

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

~/.mysql_history
mhoeffner
  • 94
  • 3
4

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

Dirk de Kok
  • 199
  • 12
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
Brian Lyttle
  • 14,558
  • 15
  • 68
  • 104
  • Old answer, I know, but it came up in a [review task](http://stackoverflow.com/review/low-quality-posts/13972167). 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. – Mike Oct 13 '16 at 15:11
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.

Dave
  • 39
  • 1
0

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

rmc
  • 1,018
  • 1
  • 9
  • 8
0

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.

float13
  • 31
  • 6
0

This did the job for me:

brew uninstall mysql
Srini
  • 1,626
  • 2
  • 15
  • 25
0
brew uninstall --force mysql@<version_no>

exmample

brew uninstall --force mysql@5.7

to get version check cd /usr/local/Cellar

Shubham kumar
  • 712
  • 7
  • 12
-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

-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.

Kunal Vyas
  • 1,499
  • 1
  • 23
  • 40
PaulD
  • 107
  • 1
  • 2
  • 6
    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. –  Oct 11 '14 at 01:41
  • 2
    faster: `sudo find / -iname "*mysql*"` – bfontaine May 06 '15 at 14:24
  • 3
    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? – Alok Kumar Nov 14 '15 at 16:08