Here’s a quick guide on how to install MySQL database on your Apple Macs.
This tutorial is aimed at Catalinas, but is high probable to work on other versions.
- Open up your
- Install homebrew using a tutorial from the official homebrew’s site: https://brew.sh/
- restart your terminal (just in case)
- now open up the terminal again and run the command
brew install mysql
- After a successful installation your MySQL server is ready
Access the console
- my default, mysql server is installed on mac without a root password and you should be able to access the mysql’s console via command
Create and access a database
Creating a MySQL database is three-step process. Firstly, you need to create a user that will be used when connecting into the database from scrips, then you have to create the database and lastly, it is needed to grant the user the permissions to access the database.
1. Create a user
Access mysql console and run the following command:
CREATE USER 'myuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'myp4$$word';
You can replace “myuser” and the password “myp4$$word” with custom values.
2. Create a database
Within the mysql console run the following command:
CREATE DATABASE my_database_name;
You can replace “my_database_name” with the name of database you are creating.
3. Grant permissions
Now grant the user the permission to the database you have just created:
GRANT ALL PRIVILEGES ON my_database_name . * TO 'myuser'@'localhost';
Now your database should be ready to READ ‘n WRITE!
While installing mysql server on your mac you may encounter various issues. In general you might encounter the following:
- while installing homebrew
- while installing mysql via homebrew
- while accessing
- while creating a mysql database
- while creating a mysql user
If you happen to encounter any issues, feel free to let me know in the comments below, try to follow the troubleshooting guide or simply google the error 🙂 .
Yours in coding,