Installing MySQL using terminal on Mac; In this tutorial, you will learn how to download, install and secure MySQL on Mac using Brew via terminal.
Install MySQL on Mac Brew
By using the following steps, you can install MySQL on Mac using Brew with terminal:
- Step 1: Install Brew
- Step 2: Install MySQL
- Step 3: Start MySQL
- Step 4: Secure MySQL
- Step 5: Connect to MySQL
Step 1: Install Brew
If you don’t have installed Homebrew on your Mac, so open your terminal or command line and execute the following command into it to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install MySQL
Now, execute the following command on the terminal to install MySQL on Mac using Brew:
brew install mysql
This command will download and install the latest version of MySQL on your Mac.
Step 3: Start MySQL
Once you have installed mysql by using the above command, then you need to start MySQL. So execute the following command on the terminal or command line to start MySQL:
mysql.server start
Step 4: Secure MySQL
By default, MySQL is not secure, and anyone with access to your Mac can access the database. Therefore, it is important to secure your MySQL installation.
Execute the following command on the terminal or command line to secure MySQL:
mysql_secure_installation
This command will open a prompt on the terminal to set a root password, remove anonymous users, disallow remote root login, and remove test databases.
Step 5: Connect to MySQL
Execute the following command on the terminal or command line to connect to MySQL:
mysql -u root -p
This will prompt you to enter the password you set for your MySQL root user. Once you enter the password, you will be connected to the MySQL server.
Conclusion
That’s it; In this tutorial, you learned how to download, install, and secure MySQL on Mac using Homebrew Terminal. The process is simple and can be completed within a few minutes. Once you’ve installed MySQL, it’s important to secure it by setting a strong root password and removing any unnecessary users and databases. With MySQL installed, you can start organizing and managing your data efficiently.