Skip to content

Instantly share code, notes, and snippets.

@vitorbritto
Last active April 16, 2026 20:35
Show Gist options
  • Select an option

  • Save vitorbritto/0555879fe4414d18569d to your computer and use it in GitHub Desktop.

Select an option

Save vitorbritto/0555879fe4414d18569d to your computer and use it in GitHub Desktop.
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:

    # Edit this file: /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

Remove MySQL completely (Apple Silicon Version)

  • brew remove mysql
  • rm -rf /opt/homebrew/var/mysql
  • brew install mysql
  • mysql.server start
  • mysql -uroot
@dannguyen

Copy link
Copy Markdown

Regarding Step 6:

sudo rm -rf /Library/PreferencePanes/My*

Is it necessary to use such a wildcard here, instead of a more explicit pattern? MySQL can't be the only thing (now, or in the future) that a user might have in /Library/PreferencePanes that begins with My, right?

@aravindcf

Copy link
Copy Markdown

Thanks a lot. I followed the same procedure. But when I typed mysql I was getting ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'. I used sudo rm -rf /usr/local/bin/mysql*. That worked.

@QubeChan

Copy link
Copy Markdown

Can you clarify on step 4? I try killing the process but it mysqld won't die it'll show up under a new id

@brendanfalkowski

Copy link
Copy Markdown

@QubeChan — I had the some problem. Documented here: https://manuals.gravitydept.com/develop/command-line/brew

I skipped it and didn't have issues with the remaining steps.

@crmpicco

Copy link
Copy Markdown

Thanks for posting

@sandokan815

Copy link
Copy Markdown

It saved my many days. thanks

@yogesh-desai

Copy link
Copy Markdown

Thank you. Great post! Saved a lot of time

@Yigaue

Yigaue commented Jan 14, 2020

Copy link
Copy Markdown

Good post. I defaulted to install DBngin and it worked for me.

@callump5

Copy link
Copy Markdown

Thanks this got it all working!

@brunofariasdeo

Copy link
Copy Markdown

Helped a lot, thank you!

@Anishmourya

Copy link
Copy Markdown

After long searching , i solved this issue , downloaded official mac os community file from :- https://dev.mysql.com/downloads/file/?id=492745
it worked for mac os Catalina 10.15 , check this link :- https://dev.mysql.com/doc/mysql-osx-excerpt/5.7/en/osx-installation-pkg.html , they also mentioned required packages to run mysql on mac os , specially "/tmp/mysql.sock" at bottom .

@cjstage

cjstage commented Apr 6, 2020

Copy link
Copy Markdown

Saved my behind.

@dannydickson

Copy link
Copy Markdown

This was very helpful. I also had to do:

rm /usr/local/etc/my.cnf

Something I had done previously had resulted in a my.cnf file that prevented MySQL from working (I was getting the dreaded ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) error).

Apparently, this config file can live in several places: /etc/my.cnf, OR /etc/mysql/my.cnf OR ~/.my.cnf. My particular install had placed it at /etc/my.cnf as well, but thought I'd drop the other options here in case anybody else is down this same rabbit hole as me one day.

Thanks to OP @vitorbritto for the great gist as well!

@vishwarajanand

Copy link
Copy Markdown

Thanks, it worked :-)

@vycz

vycz commented May 14, 2020

Copy link
Copy Markdown

Thanks

@ronaksahai

Copy link
Copy Markdown

how do we do step 8... removing the line part

@spmaniusa-hub

Copy link
Copy Markdown

Thanks a lot. It would have been good if I got this article first. I would have saved about 5 hours :-(

@msidana

msidana commented Jul 6, 2020

Copy link
Copy Markdown

Thank you so much. I wish I had landed up on this page much earlier. I struggled so much. This is an excellent page, Thanks 👍

@sammyrTX

Copy link
Copy Markdown

Thank you! Very helpful!

@swashata

Copy link
Copy Markdown

Thank you very much. It is notoriously difficult to uninstall mysql data. Your tutorial did the trick! 👍

@lexjacobs

Copy link
Copy Markdown

subl /etc/hostconfig`
has a hanging backtick

@mkomigor

Copy link
Copy Markdown

👍

@sreekanth-a1

Copy link
Copy Markdown

thank you very much

ghost commented Sep 24, 2020

Copy link
Copy Markdown

Thank you , it's help a lot !

@FahimAnayet

Copy link
Copy Markdown

Aaah, Thanks man!

@derins

derins commented Oct 12, 2020

Copy link
Copy Markdown

Thank you

@froxtrox

Copy link
Copy Markdown

Nice work! Thank you

@commadelimited

Copy link
Copy Markdown

subl /etc/hostconfig`
has a hanging backtick

Also, not everyone has sublime text. Better to simply say "edit this file".

@SorosWen

Copy link
Copy Markdown

This is very helpful! Thank you!

@CaReS0107

Copy link
Copy Markdown

On the Apple Silicon:

brew remove mysql
rm -rf /opt/homebrew/var/mysql
brew install mysql
mysql.server start
mysql -uroot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment