Skip to content

Instantly share code, notes, and snippets.

@nrollr
Last active September 19, 2024 08:26
Show Gist options
  • Save nrollr/3f57fc15ded7dddddcc4e82fe137b58e to your computer and use it in GitHub Desktop.
Save nrollr/3f57fc15ded7dddddcc4e82fe137b58e to your computer and use it in GitHub Desktop.
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

  • Enter the following command : $ brew info mysql
  • Expected output: mysql: stable 5.7.15 (bottled)

To install MySQL enter : $ brew install mysql

Additional configuration

Homebrew

  • Install brew services first : $ brew tap homebrew/services

  • Load and start the MySQL service : $ brew services start mysql.
    Expected output : Successfully started mysql (label: homebrew.mxcl.mysql)

  • Check of the MySQL service has been loaded : $ brew services list 1

  • Verify the installed MySQL instance : $ mysql -V.
    Expected output : Ver 14.14 Distrib 5.7.15, for osx10.12 (x86_64)

MySQL

Open Terminal and execute the following command to set the root password:
mysqladmin -u root password 'yourpassword'

Important : Use the single ‘quotes’ to surround the password and make sure to select a strong password!

Database Management

To manage your databases, I recommend using Sequel Pro, a MySQL management tool designed for macOS.
Current version available: 1.1.2

Comments

1 The brew services start mysql - instruction is equal to :

$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
@mlevin77
Copy link

mlevin77 commented Jan 29, 2023 via email

@lain0
Copy link

lain0 commented Sep 11, 2024

How to install [email protected] and [email protected] with brew in 2024:

1 ) Edit local brew folmula files - delete line: deprecate! date: "2023-09-11", because: :unsupported

  1. install mysql-client with only local brew files
HOMEBREW_NO_INSTALL_FROM_API=1  brew install [email protected] [email protected]
# and intall ruby gem mysql2 0.5.4 for mysql 5.7:
gem install mysql2 -v 0.5.4 -- --with-openssl-dir=$(brew --prefix [email protected])  -- --with-mysql-dir=/usr/local/opt/[email protected]/

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