Skip to content

Instantly share code, notes, and snippets.

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:

    # 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

Copy link

vishwarajanand commented May 4, 2020

Thanks, it worked :-)

Copy link

vycz commented May 14, 2020


Copy link

ronaksahai commented May 29, 2020

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

Copy link

spmaniusa-hub commented Jun 30, 2020

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

Copy link

msidana commented Jul 6, 2020

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 👍

Copy link

sammyrTX commented Jul 12, 2020

Thank you! Very helpful!

Copy link

swashata commented Aug 17, 2020

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

Copy link

lexjacobs commented Aug 19, 2020

subl /etc/hostconfig`
has a hanging backtick

Copy link

mkomigor commented Aug 26, 2020


Copy link

sreekanth-a1 commented Sep 3, 2020

thank you very much

Copy link

elgcv commented Sep 24, 2020

Thank you , it's help a lot !

Copy link

FahimAnayet commented Sep 30, 2020

Aaah, Thanks man!

Copy link

derins commented Oct 12, 2020

Thank you

Copy link

froxtrox commented Dec 27, 2020

Nice work! Thank you

Copy link

commadelimited commented Mar 12, 2021

subl /etc/hostconfig`
has a hanging backtick

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

Copy link

SorosWen commented Apr 18, 2021

This is very helpful! Thank you!

Copy link

CaReS0107 commented Apr 22, 2021

On the Apple Silicon:

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

Copy link

vitorbritto commented May 10, 2021

subl /etc/hostconfig`
has a hanging backtick

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

Thanks @commadelimited, gist updated.

Copy link

vitorbritto commented May 10, 2021

subl /etc/hostconfig`
has a hanging backtick

Thanks @lexjacobs, gist updated.

Copy link

seemly commented May 24, 2021

When setting up my Apple M1 Macbook Pro I was experiencing the issue of the following error message being thrown:

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

My fix was to modify the MySQL config file:

nano /usr/local/etc/my.cnf

Append the following lines:


Then run:

brew services restart mysql@5.7

This fixed my issue, and I was then able to connect successfully with my DB client.

Copy link

Eddievin commented Jun 20, 2021

@seemly Thanks for this

Copy link

HusseinMalingha commented Jul 28, 2021

Thanks <3

Copy link

KalisaFalzone commented Aug 10, 2021

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

Thank you! This was what I needed!

Copy link

iRiziya commented Jan 5, 2022

Awesome Thanks 😊🙌🏻

Copy link

keomony commented Jan 25, 2022

saved my day! Thank you :)

Copy link

IngmarFalk commented Mar 4, 2022

Thank god for your beautiful ass mate, I was looking for this for like an hour

Copy link

zhafed commented Apr 11, 2022

Append the following lines to:

  • /opt/homebrew/etc/my.cnf

  • /opt/homebrew/Cellar/mysql@5.7/5.7.37/.bottle/etc/my.cnf


Thanks @seemly it's worked , i spend 8 hours searching .

@seemly you saved me with these Comment : here

Copy link

bantya commented Jun 4, 2022

Thanks for this awesome guide.
@tnorthcutt's reply helped a lot!

Copy link

Rebek73 commented Jun 29, 2022

Thanks, it worked!!

Copy link

mkomigor commented Jul 1, 2022


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