Install MySQL on macOS Sierra
- 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.
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
Install brew services first :
$ brew tap homebrew/services
Load and start the MySQL service :
$ brew services start mysql.
To have launchd start mysql now and restart at login:
brew services start mysqlOr, if you don't want/need a background service you can just run:
mysql.server startExpected output : Successfully started
Check of the MySQL service has been loaded :
$ brew services list1
Verify the installed MySQL instance :
$ mysql -V.
Expected output : Ver 14.14 Distrib 5.7.15, for osx10.12 (x86_64)
Open Terminal and execute the following command to set the root password:
mysqladmin -u root password 'mysqlsecret'
Important : Use the single ‘quotes’ to surround the password and make sure to select a strong password!
To manage your databases, I recommend using Sequel Pro, a MySQL management tool designed for macOS.
Current version available: 1.1.2
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
Updating Mysql version using brew :
brew uninstall mysql brew install email@example.com brew link firstname.lastname@example.org --force brew services start email@example.com```