Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

    brew remove mysql
    brew cleanup
    
  6. 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*
    
  7. Unload previous MySQL Auto-Login:

    launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    
  8. Remove previous MySQL Configuration:

    subl /etc/hostconfig` 
    # Remove the line MYSQLCOM=-YES-
    
  9. 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*
    
  10. Restart your computer just to ensure any MySQL processes are killed

  11. Try to run mysql, it shouldn't work

@thekeele

This comment has been minimized.

Copy link

thekeele commented Nov 21, 2016

Swap 6 & 7? You're unloading a file that was deleted.

@jayantkeswani

This comment has been minimized.

Copy link

jayantkeswani commented Jan 17, 2017

Thanks for the awesome walkthrough!

@leshek-pawlak

This comment has been minimized.

Copy link

leshek-pawlak commented Jan 26, 2017

It helped me a lot. Thanks! 👍

@aryzhov

This comment has been minimized.

Copy link

aryzhov commented Feb 5, 2017

I have MySQL 5.17.14. The daemon is installed in /Library/LaunchDaemons, not in /Library/LaunchAgents. I installed by downloading a DMG archive from dev.mysql.com.

@TibiaZ

This comment has been minimized.

Copy link

TibiaZ commented Feb 14, 2017

Really useful! Thanks!

@decuyperjeremie

This comment has been minimized.

Copy link

decuyperjeremie commented Apr 4, 2017

Really really useful, thanks a lot 👍

@Joseph1209

This comment has been minimized.

Copy link

Joseph1209 commented Apr 5, 2017

pretty useful! thank u

@amithgc

This comment has been minimized.

Copy link

amithgc commented Apr 15, 2017

Awesome, Thanks

@coolcat-310

This comment has been minimized.

Copy link

coolcat-310 commented Apr 20, 2017

Thank you

@kevinzhang2012

This comment has been minimized.

Copy link

kevinzhang2012 commented May 15, 2017

successfully uninstalled, thank you

@xiayank

This comment has been minimized.

Copy link

xiayank commented Jun 9, 2017

Thx!!!

@ghost

This comment has been minimized.

Copy link

ghost commented Jun 18, 2017

Thanks a lot! That's it.

@chandu6

This comment has been minimized.

Copy link

chandu6 commented Jun 19, 2017

tnx man.

@davidmartinezfl

This comment has been minimized.

Copy link

davidmartinezfl commented Jun 28, 2017

thanks!

@maxg203

This comment has been minimized.

Copy link

maxg203 commented Aug 1, 2017

Really nice, works well. Thank you.

@jningtho

This comment has been minimized.

Copy link

jningtho commented Aug 4, 2017

This is a brilliant walkthrough! Appreciate your time and making it so smooth. :)

@techlarry

This comment has been minimized.

Copy link

techlarry commented Aug 10, 2017

Thanks a lot!

@yueyue21

This comment has been minimized.

Copy link

yueyue21 commented Aug 12, 2017

wooow, this is good

@lonelykid

This comment has been minimized.

Copy link

lonelykid commented Aug 25, 2017

I feel it's nonsense to do this. Why do we need such thing like Homebrew while it can't even uninstall a package completely for us?

@anto004

This comment has been minimized.

Copy link

anto004 commented Aug 29, 2017

Thanks this worked for me.
I completely uninstalled mysql and installed Xampp mysql comes with it.

@seokany

This comment has been minimized.

Copy link

seokany commented Sep 15, 2017

thnx!! , i 'm dont need uninstall my mac

@ashwinibaisutrave

This comment has been minimized.

Copy link

ashwinibaisutrave commented Sep 22, 2017

Thank you ,really help full

@chandan29

This comment has been minimized.

Copy link

chandan29 commented Sep 29, 2017

After trying about ten to fifteen things from different posts, this is the post that worked for me! Thanks a lot!

@anasebescen

This comment has been minimized.

Copy link

anasebescen commented Oct 6, 2017

Thank you! Very help full!

@rochapablo

This comment has been minimized.

Copy link

rochapablo commented Oct 19, 2017

I did all the process and worked then I installed again the mysql

$ brew install mysql
$ brew tap homebrew/services
$ brew services run mysql

And everything start work until today, where I tried to run my local website (as any other day) and I got:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

After that, every answer that I tried takes me to another error and so on. This is not the first time that happened and the only solution is re-install everything. So I was wondering if anyone have any idea why this could be happening. I don't want to run the entire process every time that mysql decide crash, but I want fix the problem or at least understand what is going on.

sequelize/cli#572

@nemalinde

This comment has been minimized.

Copy link

nemalinde commented Oct 30, 2017

Thanks!

@caytekin

This comment has been minimized.

Copy link

caytekin commented Oct 30, 2017

Great! Thanks.

@cAstraea

This comment has been minimized.

Copy link

cAstraea commented Oct 31, 2017

still not working :((( it's really messed up now been trying for ages... think I need to factory reset my macbook pro and start anew ... been trying to install the imagick package but not mysql stopped working

@iredmedia

This comment has been minimized.

Copy link

iredmedia commented Nov 24, 2017

Same here... mine's been butchered for almost a year.

@kumarankit1234

This comment has been minimized.

Copy link

kumarankit1234 commented Nov 28, 2017

Restart computer is very important.

@diansheng

This comment has been minimized.

Copy link

diansheng commented Dec 12, 2017

@rochapablo, i went through the same. Now after removing everything, i am going to install mysql version 5.6, and installing via the dmg file from community. https://dev.mysql.com/downloads/file/?id=463209. Then i can control via system preference panel. Hope i won't have that error anymore.

@lokatyre

This comment has been minimized.

Copy link

lokatyre commented Jan 5, 2018

It helped! Thanks!

@sriharsha-sammeta

This comment has been minimized.

Copy link

sriharsha-sammeta commented Jan 24, 2018

Thanks for saving the day ! 👍

@hubertperron

This comment has been minimized.

Copy link

hubertperron commented Feb 7, 2018

Thanks, I was going mad trying to run MySQL on a old laptop that hasn't been updated to High Sierra. This fixed it.

@mugendiz

This comment has been minimized.

Copy link

mugendiz commented Feb 10, 2018

Hey thanks, this is basically the only thing that worked

@raymonschouwenaar

This comment has been minimized.

Copy link

raymonschouwenaar commented Mar 6, 2018

This saves us a lot of time 👍

@radub

This comment has been minimized.

Copy link

radub commented Mar 27, 2018

$ brew remove mysql
Uninstalling /usr/local/Cellar/mysql/5.7.21... (323 files, 233.9MB)
mysql 5.7.20 1 is still installed.
Remove all versions with brew uninstall --force mysql.

@atuanpham

This comment has been minimized.

Copy link

atuanpham commented Apr 7, 2018

Awesome! Thank you!

@MBegum02

This comment has been minimized.

Copy link

MBegum02 commented May 7, 2018

Thanks alot!! Helped us alot!!

@dazjavier

This comment has been minimized.

Copy link

dazjavier commented Jun 6, 2018

Thanks!

@ghost

This comment has been minimized.

Copy link

ghost commented Jun 19, 2018

Thanks a million! These instructions allowed me to rollback from 8.0.11 to 5.7.

After 3 days of ripping my hair out, I can finally work again.

@algoth

This comment has been minimized.

Copy link

algoth commented Jun 19, 2018

How did you install 5.7 after uninstalling? I am trying to rollback from 8.0.11 since yesterday but unable to do so.

@borgesbiel

This comment has been minimized.

Copy link

borgesbiel commented Jun 29, 2018

worked, thanks!

@icehongssii

This comment has been minimized.

Copy link

icehongssii commented Jul 24, 2018

rm: /Users/icehongssi/Library/LaunchAgents/homebrew.mxcl.mysql.plist: No such file or directory

..

@ricketybridge

This comment has been minimized.

Copy link

ricketybridge commented Jul 25, 2018

subl results in command not found.

@mkompanets

This comment has been minimized.

Copy link

mkompanets commented Jul 30, 2018

Had to also do this: sudo rm -rf /usr/local/bin/mysql

@redolivedev

This comment has been minimized.

Copy link

redolivedev commented Jul 31, 2018

@algoth brew install mysql@5.7

@ryuchan00

This comment has been minimized.

Copy link

ryuchan00 commented Aug 6, 2018

Thank you this gist.

@coreyderosa

This comment has been minimized.

Copy link

coreyderosa commented Sep 19, 2018

I freaking love you!!

@pratyesh

This comment has been minimized.

Copy link

pratyesh commented Oct 15, 2018

Thanks

@thatssushmit

This comment has been minimized.

Copy link

thatssushmit commented Nov 3, 2018

I did all the process and worked then I installed again the mysql

$ brew install mysql
$ brew tap homebrew/services
$ brew services run mysql

And everything start work until today, where I tried to run my local website (as any other day) and I got:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

After that, every answer that I tried takes me to another error and so on. This is not the first time that happened and the only solution is re-install everything. So I was wondering if anyone have any idea why this could be happening. I don't want to run the entire process every time that mysql decide crash, but I want fix the problem or at least understand what is going on.

sequelize/cli#572

hey dear you can fix your problem by running
mysql.server start

@athomas-wtv

This comment has been minimized.

Copy link

athomas-wtv commented Nov 15, 2018

In step 8, it's' supposed to read:
sudo /etc/hostconfig

for anyone having issues.
@ricketybridge

@lsantamaria

This comment has been minimized.

Copy link

lsantamaria commented Dec 22, 2018

Thanks!

@peanutgao

This comment has been minimized.

Copy link

peanutgao commented Jan 3, 2019

Thanks

@ianrandmckenzie

This comment has been minimized.

Copy link

ianrandmckenzie commented Jan 10, 2019

For me the line:
sudo rm -rf /usr/local/var/mysql
Was the main fix. I reinstalled mysql@5.7 after removing that folder and everything worked. The super weird thing, however, is it took me several attempts at deleting that file to get things to finally work. I have no idea what I did differently the final time to get it to work, but hopefully this message points someone in the right direction.

Also: I completely removed MAMP from my machine, so that might have helped somewhere along the way as well. At this stage of my development skill, I no longer need MAMP under my toolbelt.

@Hanyuxiaoorz

This comment has been minimized.

Copy link

Hanyuxiaoorz commented Jan 26, 2019

It is useful for installed by homebrew.

@vaimeo

This comment has been minimized.

Copy link

vaimeo commented Jan 29, 2019

Perfect i just love the people like you to explain simple words

@liz282907

This comment has been minimized.

Copy link

liz282907 commented Feb 12, 2019

thanks!

@thehackercat

This comment has been minimized.

Copy link

thehackercat commented Feb 14, 2019

good

@joaovcarvalho

This comment has been minimized.

Copy link

joaovcarvalho commented Mar 9, 2019

Great! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.