Installing and Running MySQL on Mac

Writing by on Friday, 27 of May , 2016 at 7:35 am

Painful process, but you will need to see what works for you.

Say you’ve done the following:

  • Downloaded the DMG and installed MySQL on your Mac (and it provided you a password)
  • Started it from System Preferences -> MySQL
  • Now you tried different ways to connect to MySQL but are not able to login to localhost
  • So, then you tried brew and it didn’t work. Go ahead and remove mysql from brew
    • sudo brew remove mysql
    • brew cleanup

Now, here’s what worked for me, thanks to the following:

  • https://www.variphy.com/support/knowledge-base/mac-os-x-reset-mysql-root-password
  • http://stackoverflow.com/questions/30692812/mysql-user-db-does-not-have-password-columns-installing-mysql-on-osx

# Start MySQL in Safe Mode
$ sudo /usr/local/mysql/bin/mysqld_safe –skip-grant-tables

# Connect to MySQL as root (without password)
$ sudo /usr/local/mysql/bin/mysql -u root

# Update the password
mysql>use mysql;
mysql>show tables;
mysql> update user set authentication_string=password(‘new_password’) where user=’root’;

# Kill the mysql safe process and start it from System Preferences -> MySQL
alias mysql=’/usr/local/mysql/bin/mysql -uroot -ppassword’

That worked for me and I was able to kill the mysql safe-mode process and connect to MySQL through CLI as well as a GUI like Sequel Pro.

Optionally, to add python drivers that will fail further if the following is not done.

# add this to your $PATH
export PATH=$PATH:/usr/local/mysql/bin

# pip install in the right venv
pip install MySQL-python

Leave a comment

Category: Mac,SQL DB

No Comments

No comments yet.

Leave a comment

You must be logged in to post a comment.

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.