To install MySQL on macOS, you can use Homebrew, which is a popular package manager for macOS. Here are the steps to install MySQL using Homebrew:
-
Install Homebrew:
If you don't have Homebrew installed, you can install it by running the following command in your terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Install MySQL:
Once Homebrew is installed, you can use it to install MySQL. Run the following commands in your terminal:
brew update brew install mysql
-
Start MySQL Server:
After the installation is complete, you can start the MySQL server with the following command:
brew services start mysql
This command will start the MySQL server and configure it to start automatically on system startup.
-
Secure MySQL Installation (Optional):
It is recommended to run the MySQL secure installation script to improve the security of your MySQL installation. This script will prompt you to set a root password, remove anonymous users, disallow root login remotely, and remove the test database. Run the following command and follow the instructions:
mysql_secure_installation
Follow the prompts to configure MySQL based on your preferences.
-
Access MySQL:
You can access the MySQL command-line interface by typing the following command and entering your password when prompted:
mysql -u root -p
Replace
root
with your MySQL username if you have chosen a different username during installation.
That's it! You should now have MySQL installed and running on your macOS system. Remember to consult the MySQL documentation for further configuration and management options: MySQL Documentation.