How to Install MySQL on Windows
To learn MySQL you need a MySQL server on your computer. This guide installs the free MySQL Community Server on Windows step by step, then shows quick ways to install it on macOS, Linux and Docker. At the end you will connect to the server and run your first command.
1. Before You Start
- Windows 10 or 11, 64-bit, with administrator rights.
- About 1 GB of free disk space and an internet connection for the download.
- Microsoft Visual C++ Redistributable (2019 or later). The installer tells you if it is missing; it is a free download from Microsoft.
- Choose a version: the latest LTS release (8.4 at the time of writing) is the safe choice for learning and production. Innovation releases (9.x) add newer features but have short support.
2. Step 1: Download the Installer
- Open
https://dev.mysql.com/downloads/mysql/in your browser. - Select the version (for example 8.4.x LTS) and the operating system Microsoft Windows.
- Download the Windows (x86, 64-bit), MSI Installer.
- On the next page click No thanks, just start my download; an Oracle account is not required.
3. Step 2: Run the MSI Installer
- Double-click the downloaded
.msifile and click Next. - Accept the licence agreement.
- Choose Typical setup (server, client programs and tools).
- Click Install and allow the Windows permission prompt.
- Leave Run MySQL Configurator ticked and click Finish.
The programs are copied to C:\Program Files\MySQL\MySQL Server 8.4\. The server is not running yet; Configurator sets it up next.
4. Step 3: Configure the Server with MySQL Configurator
| Screen | What to choose | Why |
|---|---|---|
| Data Directory | Keep the default C:\ProgramData\MySQL\MySQL Server 8.4\ | Where your databases are stored |
| Type and Networking | Config type Development Computer; TCP/IP port 3306; tick Open Windows Firewall port only if other machines must connect | Uses less memory on a laptop; 3306 is the standard port |
| Accounts and Roles | Set a strong root password and write it down. Optionally add a normal user for daily work | root is the all-powerful admin account |
| Windows Service | Tick Configure MySQL Server as a Windows Service, name MySQL84, Start at System Startup | MySQL starts automatically with Windows |
| Server File Permissions | Keep the default (grant full access to the service account) | Protects the data folder |
| Sample Databases | Optional: sakila and world | Handy practice data |
| Apply Configuration | Click Execute and wait for all green ticks, then Finish | Creates the data folder and starts the service |
5. Step 4: Add MySQL to the PATH
To run mysql from any folder, add its bin directory to the Windows PATH:
- Press the Windows key, type environment variables and open Edit the system environment variables.
- Click Environment Variables…, select
Pathunder System variables and click Edit. - Click New and add
C:\Program Files\MySQL\MySQL Server 8.4\bin. - Click OK three times, then open a new Command Prompt or PowerShell window.
6. Step 5: Connect and Test
Check that the client is found, then log in as root with the password you chose:
mysql --version
mysql -u root -p
The first command prints the client version. After the second, type your password; you should see the mysql> prompt. Now run a few statements:
SELECT VERSION() >= '8.0' AS modern_mysql, NOW() IS NOT NULL AS server_clock_ok;
SHOW DATABASES;
Result: 1 row
| modern_mysql | server_clock_ok |
|---|---|
| 1 | 1 |
Result: 4 rows
| Database |
|---|
| information_schema |
| mysql |
| performance_schema |
| sys |
Type exit (or \q) to leave the client.
localhost:3306 as root.7. Starting and Stopping the Service
MySQL runs as a Windows service. You can control it from Services (services.msc) or from an administrator Command Prompt:
net stop MySQL84
net start MySQL84
sc query MySQL84
8. Installing on macOS, Linux and Docker
| Platform | Quick install | Notes |
|---|---|---|
| macOS | Download the DMG (ARM or x86) from dev.mysql.com and run the package; or brew install mysql | The DMG adds a MySQL pane to System Settings to start/stop the server |
| Ubuntu / Debian | Add the MySQL APT repository (mysql-apt-config) then sudo apt install mysql-server | Ubuntu's own repository also has mysql-server, often a slightly older version |
| RHEL / Oracle Linux / Fedora | Install the MySQL Yum repository RPM, then sudo dnf install mysql-community-server | A temporary root password is written to /var/log/mysqld.log |
| Docker (any OS) | docker run --name mysql84 -e MYSQL_ROOT_PASSWORD=Secret#123 -p 3306:3306 -d mysql:8.4 | Add -v mysqldata:/var/lib/mysql to keep data when the container is removed |
# Linux (systemd): manage the service
sudo systemctl start mysqld # service is called 'mysql' on Ubuntu/Debian
sudo systemctl enable mysqld
sudo mysql_secure_installation # set root password, remove test database
9. First Things to Do After Installing
Working as root every day is risky. Create your own user and a practice database:
CREATE DATABASE practice;
CREATE USER 'learner'@'localhost' IDENTIFIED BY 'Learn#MySQL2026';
GRANT ALL PRIVILEGES ON practice.* TO 'learner'@'localhost';
SHOW GRANTS FOR 'learner'@'localhost';
Result: 2 rows
| Grants for learner@localhost |
|---|
| GRANT USAGE ON *.* TO `learner`@`localhost` |
| GRANT ALL PRIVILEGES ON `practice`.* TO `learner`@`localhost` |
From now on connect with mysql -u learner -p practice.
10. Troubleshooting
| Problem | Likely cause and fix |
|---|---|
'mysql' is not recognized as an internal or external command | The bin folder isn't in PATH, or the window was opened before you changed PATH. Repeat Step 4 and open a new window. |
ERROR 1045 (28000): Access denied for user 'root'@'localhost' | Wrong password, or you typed it after -p with a space. Use -p alone and type it at the prompt. |
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost:3306' | The service isn't running. Start it with net start MySQL84 or from Services. |
| Configurator fails at Starting the server | Port 3306 is used by another program (or another MySQL). Choose a different port or stop the other program. |
| Installer complains about Visual C++ | Install the latest Microsoft Visual C++ Redistributable (x64) and run the MSI again. |
11. Summary
- Download the MySQL Community Server MSI (choose an LTS version) from dev.mysql.com.
- Install it, then use MySQL Configurator to set the port, root password and Windows service.
- Add the
binfolder to PATH and test withmysql -u root -p. - On macOS use the DMG or Homebrew; on Linux use the official APT/Yum repositories; anywhere, Docker works.
- Create a normal user for daily work instead of using root.