Step 1: Install Homebrew
If you don't have Homebrew you can install it using the command line below.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Update Homebrew Repository
Step 3: Install MySQL Using Homebrew
Now run the brew install command and specify MySQL as the package to install. Once that's done you need to start the MySQL using the brew services start command.
brew install mysql brew services start mysql
Step 4: Check MySQL status, start and stop
To check the MySQL running states you can run the following commands.
brew services list
brew services restart mysql brew services start mysql brew services stop mysql
Step 4: Access MySQL from Terminal
To test and access MySQL from the terminal you can use the "mysql" command and specify the username and password as you have entered in the installation above.
mysql -u root -p