How to use MySQL on Mac
November 9, 2023
This guide provides step-by-step instructions for installing and using MySQL on macOS. It's tailored for engineers looking to get MySQL up and running quickly and efficiently.
1. Installing MySQL
If you don't have Homebrew installed, you'll want to start there:
Once Homebrew is installed:
- Go to the official MySQL website's download page and download the macOS version of MySQL Community Server.
- Open the downloaded DMG file.
- Follow the installation instructions.
2. Starting and Stopping the MySQL Server
3. Connecting to the MySQL Server
By default, MySQL creates a user
root with no password. You can connect to the MySQL server with the following command:
If you've set a password for
It will then prompt you for the password.
4. Basic MySQL Commands
Once connected, here are a few basic commands to get started:
- Show all databases:
- Create a new database:
CREATE DATABASE dbname;
- Switch to a database:
- Show all tables in the current database:
- Display structure of a table:
Remember to end each command with a semicolon (
5. Uninstalling MySQL
Stop the MySQL server:
Remove MySQL files:
Remove MySQL preferences:
Remove the MySQL user and group (be cautious with this step):
That's it! You should now have a solid foundation for using MySQL on your Mac. As always, consult the official MySQL documentation for deeper dives into specific topics and advanced configurations.
Not Equal in MySQL
How to Drop a User in MySQL
Duplicate Column Name in MySQL
Backticks in MySQL: An Overview
How to Set a Timer in MySQL
How to Fix the Illegal Mix of Collations Error in MySQL