Javatpoint Logo
Javatpoint Logo

How to Install MySQL on MacOS

Introduction

MySQL is an opensource, relational database management system. Its name is the combination of two words that are My + SQL where my is the name of co-founder Michael Widenius's daughter and SQL is the abbreviation of Structured Query Language.

MySQL is widely used as a database system in various well-known companies like Google and Facebook. In this tutorial, we will learn the installation process of MySQL server on MacOS.

Prerequisites

  • MacOS
  • Login as an administrator on terminal.

Installation

Following steps are used to install MySQL on MacOS.

1) Download the latest version

Download the latest version of MySQL community server that is 5.7.20 from its official website or simply copy and paste https://dev.mysql.com/downloads/file/?id=473576 into our browser search bar. The file will be downloaded in disk image format which is to be mounted first on our volumes directory.

2) Mount the disk image file

Hdiutil is used with the mount option to mount the disk image file on volumes directory of root.

Macos MySql 1

3) Using Installer to Install MySQL package

The command installs MySQL community server to the root directory. During the installation process, it also sets the default password for root to access MySQL.

Macos MySql 2

When we install MySQL on MacOS, a default username and password is created which is shown to the user at the time of installation.

Macos MySql 3

4) Unmount the Disk Image File

The MySQL package mounted on volumes directory needs to be unmounted. Hdiutil is used with the unmount option to do so.

Macos MySql 4

5) Starting MySQL

On MacOS, all the support files are located at /usr/local/MySQL. Support-Files contains MySQL.server which is actually started when we need to access our database. We must have the path information of MySQL server in order to start MySQL. We must have super user permissions to start and stop MySQL database.

Macos MySql 5

6) Working on MySQL Command Line

1. Accessing from command line

To run MySQL from command line, we need to start MySQL server first. Then, following command will be executed.

Where root is the username and password is r>mpyW,-J4xS .

Macos MySql 6

2. Create database

To create database, we need to execute a SQL query which is as follows.

Macos MySql 7

7) Stopping MySQL

To stop database, use the following command.

Macos MySql 8




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA