DEV Community

Cover image for MySQL in Mac (M1)
Emmanuel Morales
Emmanuel Morales

Posted on

MySQL in Mac (M1)

Pre-Requisites

  • I'll use Homebrew as the package manager.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Enter fullscreen mode Exit fullscreen mode

Installing MySQL

  • Install MySQL:
brew install mysql
Enter fullscreen mode Exit fullscreen mode
  • Before setting up MySQL we have to start the brew services
brew services start mysql
Enter fullscreen mode Exit fullscreen mode

Note: To stop mysql we set

brew services stop mysql

Setting up MySQL

Without Password

  • We just type:
mysql -uroot
Enter fullscreen mode Exit fullscreen mode

and our session is on, we can exit the session by typing

mysql> exit
Enter fullscreen mode Exit fullscreen mode

With Password

  • We type:
mysql_secure_installation
Enter fullscreen mode Exit fullscreen mode

Note: ”Validate password component" needs a secure sequence of characters to set the password, this include as minimum 8 characters and other more patterns.
If we set y (yes), it'll require that pattern, if we don't want that it, we just set n (no).

  • Recommended answers in the installation
# Remove anonymous users?:
y
#Disallow root login remotely?:
n
# Remove test database and access to it?:
y
# Reload Privilege tables now?:
y
Enter fullscreen mode Exit fullscreen mode
  • To start the mysql session with password we just type:
mysql -uroot -p
Enter fullscreen mode Exit fullscreen mode

and it will ask the password.

Top comments (0)