Setting up MySQL is the first step toward working with relational databases. Below is a complete guide to help you install and run MySQL on your system, whether you are using Windows, Linux, or macOS. The second step is to start and stop MySQL service on your system. This ensures the MySQL server is running and ready to accept connections and execute queries.
Below is a complete guide covering both steps — installation and managing the MySQL service — for all major platforms.
Step 1: Installing MySQL
- On Windows:
- Go to the official MySQL download page:
👉 https://dev.mysql.com/downloads/installer
- Download the MySQL Installer for Windows (either web or full version).
- Run the installer and select the setup type:
- Developer Default (recommended for most users)
- Server Only
- Custom
- Follow the setup wizard to:
- Install MySQL Server and MySQL Workbench
- Set a root password
- Configure MySQL as a Windows service
- Finish the installation and test it using MySQL Workbench or Command Line.
- On Linux (Ubuntu/Debian):
sudo apt update
sudo apt install mysql-server
sudo systemctl start mysql
sudo systemctl enable mysql
You can secure the installation with: sudo mysql_secure_installation
- On macOS (Using Homebrew):
- Make sure Homebrew is installed. Then run:
brew update
brew install mysql
- Set root password:
mysql_secure_installation
Step 2: Starting and Stopping MySQL Service
Once installed, you’ll often need to start or stop the MySQL service.
- On Windows:
To start or stop MySQL service:
net start mysql
net stop mysql
Run in: Command Prompt (Start > cmd) or PowerShell
- On Linux:
sudo systemctl start mysql
sudo systemctl stop mysql
sudo systemctl status mysql
Run in: Terminal
- On macOS:
brew services start mysql
brew services stop mysql
Run in: Terminal