Skip to content

Instantly share code, notes, and snippets.

@bugzbrown
Created June 4, 2019 01:20
Show Gist options
  • Save bugzbrown/6636ebbbd6b4719ce93c8aa51ab52243 to your computer and use it in GitHub Desktop.
Save bugzbrown/6636ebbbd6b4719ce93c8aa51ab52243 to your computer and use it in GitHub Desktop.
Step by step fix for mysql problems on mac.

FIX MYSQL INSTALL ON MAC

Make sure You have open ssl

brew install openssl

If you are installing Mysql 8:

see if you have a /etc/my.cnf if you do, rename it to something like old.my.cnf so that Mysql cannot find it.

Trouble wtih mysql8

UNINSTALL ALL MYSQLS

I had trouble with mysql 8 and ended reverting to @5.7

I uninstalled all mysql versions following this script:

KILL PROCESSES AND CLEAN UP

  • ps -ax | grep mysql
  • stop and kill any MySQL processes
  • brew remove mysql
  • brew cleanup

This will erase all files and databases you might have

If you don't want to run the risk, rather than sudo rm move the files to a folder such as /old/

  • sudo rm /usr/local/mysql
  • sudo rm -rf /usr/local/var/mysql
  • sudo rm -rf /usr/local/mysql*

Cleanup preferences and launchers

  • sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  • sudo rm -rf /Library/StartupItems/MySQLCOM
  • sudo rm -rf /Library/PreferencePanes/My*
  • 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

(reference: [http://soatechlab.blogspot.com/2011/01/completely-remove-mysql-on-mac-os-x.html] )

Install mysql 5.7

Most of my clients run mysql@5.7 so I prefer to have this version on my mac. When I need, on ocasion another version I'll use Docker for that.

To install mysql@5.7:

Install services for Brew - allows brew to controll the services:

brew tap homebrew/services

Install Mysql 5.7, link & start it

brew install mysql@5.7
brew link mysql@5.7 --force
brew services start mysql@5.7

You should have a mysql instance running.

Finally, setup your root password with:

mysqladmin -u root password 'yourpassword'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment