Skip to content

Instantly share code, notes, and snippets.

@vitorbritto
Last active December 20, 2024 09:43
Show Gist options
  • Save vitorbritto/0555879fe4414d18569d to your computer and use it in GitHub Desktop.
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
@SaimumIslam
Copy link

sudo rm -rf /opt/homebrew/etc/my.cnf

does the trick for me

@YUN-RU-TSENG
Copy link

YUN-RU-TSENG commented Nov 29, 2022

it works, i remove MySQL 8 successfully.
Thanks

@SeFeX
Copy link

SeFeX commented Dec 7, 2022

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:

tmpdir=/tmp
user=root

Then run:

brew services restart mysql@5.7

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

This works!

@websterl3o
Copy link

On the Apple Silicon:

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

just running this already fixed it for me

@BranchDev110
Copy link

I installed mysql v5 through package.
How can I uninstall that?

@mhbaando
Copy link

Thanks it worked for me

@ArifaAbid
Copy link

Thanks, it help a lot

@Thlenzi
Copy link

Thlenzi commented Oct 13, 2023

Great Job!!! It worked for me !!!

@nghitruongdev
Copy link

Thanks, it worked!

@AldianBaim
Copy link

Thank you very much, finnaly this method is solved my problem!

@wltrallen2
Copy link

OMG! Needed this for hours. Finally found this. Thank you!

@Kiansaziz
Copy link

Thnaks, it worked !

@martris
Copy link

martris commented Mar 15, 2024

brew remove mysql rm -rf /opt/homebrew/var/mysql brew install mysql mysql.server start mysql -uroot
this would work , but I noticed that there is another version of mysql on my mac:
> mysql -V mysql Ver 14.14 Distrib 5.7.24, for osx11.1 (x86_64) using EditLine wrapper
Later use this command :type -a mysql
It shows that anaconda3 installed a old version automatically.Ops....
mysql is /opt/anaconda3/bin/mysql
Remove it , then reinstall.

@andragri
Copy link

andragri commented Apr 8, 2024

@seemly god bless you! I spend about 8 hours to look for an answer that could help me

@Walrus-Dreamer
Copy link

Thank you! You just saved my life with this tutorial!!!!!

@Teslima02
Copy link

brew remove mysql rm -rf /opt/homebrew/var/mysql brew install mysql mysql.server start mysql -uroot this would work , but I noticed that there is another version of mysql on my mac: > mysql -V mysql Ver 14.14 Distrib 5.7.24, for osx11.1 (x86_64) using EditLine wrapper Later use this command :type -a mysql It shows that anaconda3 installed a old version automatically.Ops.... mysql is /opt/anaconda3/bin/mysql Remove it , then reinstall.

@martris Thank you

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