Prerequisites
HomeBrew
- Install brew using the official HomeBrew Installation instructions
- Go ahead if already installed
Installing MySQL
To install MySQL, run the following command in your MacOS terminal:
brew install mysql
Running MySQL
To start MySQL server, run the following command:
brew services start mysql
Verifying
To check whether MySQL server is running, run the following command:
brew services list
Usage
mysql -u root
Password
For setting Password and other configuration, run the following command after MySQL server has started
mysql_secure_installation
Usage after Password
mysql -u root -p
Then enter the password.
Stopping
To stop MySQL server,
brew services stop mysql