Signup to the waiting list!
On macOS, you can install MySQL easily using Homebrew.
brew install mysql
The above command should take a while, then print something like this:
You can now start the MySQL server by running:
brew services start mysql
Now we need to secure the MySQL server. By default the server comes without a root password, so we need to make sure it’s protected.
The procedure can take a while, but it gives a lot of power to make sure you get the best defaults out of the box:
Since we used
brew services start mysql to start MySQL, your Mac will re-start it at reboot. You can run:
brew services stop mysql
to stop this from happening, and also to immediately stop MySQL.
You can also avoid this daemon mode (that’s what we call programs that always run in the background and restart when the computer is restarted) by running:
This will start MySQL and will keep it running until the computer is shut down, or until you run:
and it will not re-start it at reboot.
It’s up to you to decide which one you prefer.
Now you can connect to the server using the command:
mysql -u root -p
You will need to type the
root user password after you run this command, and once you are done you should see this screen:
A great GUI (graphical) software we can use to interact with a SQLite database is TablePlus.
It comes with a free trial that’s perfect for our usage, because it’s not time-based but rather it limits the amount of concurrent connections you can make to the database.
Download it from https://tableplus.com. I know there are macOS, Windows and Linux versions.
Click “Create a new connection…” and select MySQL in the list:
then set a name for the connection, and enter “root” and the password you set previously:
Connect, and you should be connected to MySQL!
Note that we are connected using the
root user, which should only be used for administration purposes.
Day to day use of a database should be done using a normal user. We’ll see it in a separate tutorial.
More database tutorials:
- The MongoDB basics tutorial
- How MongoDB is different from a SQL database
- Information systems, data and information
- Data models
- Introduction to the ER Data Model
- The Relational Model
- Relational Algebra
- Relational Databases
- What is a Database? And a DBMS?
- Introduction to SQL
- How to install PostgreSQL on macOS
- Do you always need a database for your app?
- How to install SQLite on macOS
- Introduction to PostgreSQL
- PostgreSQL User Permissions
- How to list all users in PostgreSQL
- How to switch database using PostgreSQL
- How to list all databases using PostgreSQL
- How to list tables in the current database using PostgreSQL
- How to install MySQL on macOS
- Creating a user on MySQL
- PostgreSQL vs MySQL, a comparison
- SQLite User Permissions
- MySQL User Permissions
- SQL, creating a table
- SQL, adding data to a table
- SQL, how to use SELECT
- SQL, Handling empty cells
- SQL, Unique and Primary keys
- SQL, how to update data
- SQL, how to update a table structure
- SQL, how to delete data and tables
- SQL Joins
- SQL Views
- How to insert multiple items at once in a MongoDB collection
- How to remove all items from a MongoDB collection