Skip to content

Instantly share code, notes, and snippets.

@shihabmi7
Forked from nrollr/MySQL_macOS_Sierra.md
Last active October 24, 2019 08:14
Show Gist options
  • Save shihabmi7/3db81750f75944f0f70049ee628ef9e0 to your computer and use it in GitHub Desktop.
Save shihabmi7/3db81750f75944f0f70049ee628ef9e0 to your computer and use it in GitHub Desktop.
Install MySQL on Hi-Sierra using Homebrew : Tested

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

RUN mysql service

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

Enter mysql Database

$ mysql -u root -p
Enter password: enter your password 
After that you will enter mysql with mysql> tag

Show Databases

mysql> show databases

Create Database

mysql> create database your_database_name_here

To Use Your Database

mysql> use your_database_name_here
Database changed

To exit from Mysql

mysql> exit
Bye // get it from mysql console.

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