Kaigai Blog living abroad in my twenties

【My Study Note】MySQL Environment Setup (macOS)

MySQL Programming

MySQL Environment Setup (macOS)

1. Installing Homebrew

// Check whether this is already installed on your computer or not
brew -v
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2. Installing MySQL

// Check whether this is already installed on your computer or not
mysql --version
brew install mysql@5.7

3. Path Setup

We have now successfully installed MySQL, but at this current stage we are still unable to run MySQL commands. In order to make this possible, we must set and specify the path to the file that runs MySQL.

echo 'export PATH = "usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

4. Password Setup

//start up MySQL
brew services start mysql@5.7
// Set up a password
mysql_secure_installation

5. Logging into MySQL

// Starting up MySQL
brew services start mysql@5.7
// Login
mysql --user=root --password
// Logout
exit;
 // Stopping MySQL
brew services stop mysql@5.7