Before you can start working with MySQL, you need to install it on your computer. MySQL is available for all major operating systems — Windows, macOS, and Linux — and the installation process is beginner-friendly. This guide walks you through each platform step by step.
MySQL comes in two main editions:
MySQL works on all three major platforms. Choose the one that matches your computer:
The easiest way to install MySQL on Windows is through the official MySQL Installer. It is a guided setup wizard that installs MySQL Server and optionally MySQL Workbench (a visual management tool) in one go.
dev.mysql.com/downloads/installer/ — choose the MySQL Installer for Windows. Download the full offline installer (the larger file, around 400–500 MB).
.msi file. If prompted by Windows security, click Yes to allow it to run.
There are two ways to install MySQL on macOS — using the official .dmg package or using Homebrew (a macOS package manager). Both methods work well.
dev.mysql.com/downloads/mysql/ and select the macOS DMG Archive that matches your macOS version and chip (Intel or Apple Silicon).
.dmg file and follow the installation wizard. Set your root password when prompted.
If you already have Homebrew installed, this is the fastest way:
brew install mysql
After installation, start the MySQL service with:
brew services start mysql
Then run the security setup to set your root password:
mysql_secure_installation
MySQL is available directly from the default Linux package repositories. Open your terminal and run the following commands one by one:
sudo apt update
sudo apt install mysql-server
sudo systemctl start mysql
sudo mysql_secure_installation
This interactive script will guide you through setting a root password, removing anonymous users, and disabling remote root login — all good security practices for a fresh installation.
dnf or yum instead of apt. The MySQL package name may also vary — check the official MySQL documentation for your specific Linux distro.
If you are learning PHP and MySQL together, installing a local development environment like XAMPP or Laragon is an even easier approach. These tools bundle Apache, PHP, and MySQL into a single installation — no manual configuration needed.
| Tool | OS Support | Includes MySQL | Best For |
|---|---|---|---|
| XAMPP | Windows, macOS, Linux | ✔ Yes | Beginners learning PHP + MySQL |
| Laragon | Windows | ✔ Yes | Fast, modern local dev environment |
| MAMP | macOS, Windows | ✔ Yes | macOS developers |
| MySQL Installer | Windows | ✔ Yes | Standalone MySQL setup |
Once MySQL is installed, open a terminal or command prompt and log in to confirm it is working:
mysql -u root -p
You will be asked to enter your root password. After logging in successfully, you should see the MySQL prompt:
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql>
If you see the mysql> prompt, your installation is working correctly! You can now run SQL commands. Type exit; to close the MySQL client.
apt or yum and run mysql_secure_installation afterwardmysql -u root -p in the terminal