00:00

How to Install MySQL on Windows

Last updated: 6 min read

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.
MySQL installation steps on WindowsFive steps: download the MSI, run the installer, configure the server with MySQL Configurator, add the bin folder to PATH, and connect with the mysql client to test.1. DownloadMSI installer2. Installrun the .msi3. ConfigureConfigurator4. Add to PATHthe bin folder5. Testmysql -u root -pAbout 10 minutes on a typical PCAfter step 5 you can run SQL from any terminal
Figure 1: the five steps to a working MySQL server on Windows.

2. Step 1: Download the Installer

  1. Open https://dev.mysql.com/downloads/mysql/ in your browser.
  2. Select the version (for example 8.4.x LTS) and the operating system Microsoft Windows.
  3. Download the Windows (x86, 64-bit), MSI Installer.
  4. On the next page click No thanks, just start my download; an Oracle account is not required.
Older guides mention MySQL Installer, an all-in-one tool. It was used for MySQL 8.0 and is no longer provided for newer versions. Today each product (Server, Workbench, Shell) has its own MSI, and the server is configured with MySQL Configurator.

3. Step 2: Run the MSI Installer

  1. Double-click the downloaded .msi file and click Next.
  2. Accept the licence agreement.
  3. Choose Typical setup (server, client programs and tools).
  4. Click Install and allow the Windows permission prompt.
  5. 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

ScreenWhat to chooseWhy
Data DirectoryKeep the default C:\ProgramData\MySQL\MySQL Server 8.4\Where your databases are stored
Type and NetworkingConfig type Development Computer; TCP/IP port 3306; tick Open Windows Firewall port only if other machines must connectUses less memory on a laptop; 3306 is the standard port
Accounts and RolesSet a strong root password and write it down. Optionally add a normal user for daily workroot is the all-powerful admin account
Windows ServiceTick Configure MySQL Server as a Windows Service, name MySQL84, Start at System StartupMySQL starts automatically with Windows
Server File PermissionsKeep the default (grant full access to the service account)Protects the data folder
Sample DatabasesOptional: sakila and worldHandy practice data
Apply ConfigurationClick Execute and wait for all green ticks, then FinishCreates the data folder and starts the service
If you forget the root password you will need a recovery procedure, so store it in a password manager.

5. Step 4: Add MySQL to the PATH

To run mysql from any folder, add its bin directory to the Windows PATH:

  1. Press the Windows key, type environment variables and open Edit the system environment variables.
  2. Click Environment Variables…, select Path under System variables and click Edit.
  3. Click New and add C:\Program Files\MySQL\MySQL Server 8.4\bin.
  4. 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:

Command Prompt
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:

query.sql
SELECT VERSION() >= '8.0' AS modern_mysql, NOW() IS NOT NULL AS server_clock_ok;
SHOW DATABASES;

Result: 1 row

modern_mysqlserver_clock_ok
11

Result: 4 rows

Database
information_schema
mysql
performance_schema
sys

Type exit (or \q) to leave the client.

Prefer a graphical tool? Install MySQL Workbench (separate MSI) or use the database tools in IntelliJ IDEA or VS Code, and connect to 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:

Administrator Command Prompt
net stop MySQL84
net start MySQL84
sc query MySQL84

8. Installing on macOS, Linux and Docker

PlatformQuick installNotes
macOSDownload the DMG (ARM or x86) from dev.mysql.com and run the package; or brew install mysqlThe DMG adds a MySQL pane to System Settings to start/stop the server
Ubuntu / DebianAdd the MySQL APT repository (mysql-apt-config) then sudo apt install mysql-serverUbuntu's own repository also has mysql-server, often a slightly older version
RHEL / Oracle Linux / FedoraInstall the MySQL Yum repository RPM, then sudo dnf install mysql-community-serverA 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.4Add -v mysqldata:/var/lib/mysql to keep data when the container is removed
Terminal
# 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:

first-steps.sql
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

ProblemLikely cause and fix
'mysql' is not recognized as an internal or external commandThe 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 serverPort 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 bin folder to PATH and test with mysql -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.