Part · Chapter

Install MySQL on Windows

Put a real MySQL server on your own Windows 11 machine, find its files, and connect to it for the first time.

The short version

  • Install 9.7 LTS. The newest long-term line; pick 8.4 LTS if work runs that.
  • Two programs. The server MSI copies the files, MySQL Configurator makes them run.
  • Service name. MySQL97 for 9.7, MySQL84 for 8.4.
  • Config and data. Both under C:\ProgramData\MySQL\MySQL Server 9.7\.
  • PATH is your job. Add the bin folder, then open a new terminal.
  • Verify. mysql -u root -p, then SELECT VERSION();.

Before you start

You need a server you own, because practice websites never let you create a user, take a backup or read an error log.

What you need

  • Windows 11, 64-bit. MySQL for Windows is 64-bit only; check with winver.
  • An administrator account. The MSI, the service and the firewall rule need one.
  • The Visual C++ 2019 (v14) Redistributable. Without it the service dies with a missing VCRUNTIME140.dll; step 1 installs it.
  • About a gigabyte of disk.

Which edition, which line

Community Server is free and this course uses it; Enterprise Edition is paid. An LTS line keeps five years of premier support and removes nothing inside it; an Innovation release lives only until the next one.

9.7.2 LTS

April 2026, premier support to 2031.

8.4.11 LTS

April 2024, premier support to 2029.

26.7.0 Innovation

July 2026, ends when 26.10 ships.

8.0.46

End of life since April 2026.

Install the line your workplace runs, or 9.7 LTS if you do not know it. Only the version digits in paths change.

Where to download

Each product is its own download now:

Oracle asks you to log in. Look below the buttons for "No thanks, just start my download."

Careful

The old all-in-one "MySQL Installer for Windows", which most tutorials still show, installs only 8.0 and is out of support. For 8.4 and later the server MSI bundles MySQL Configurator.

Step by step: the MSI and MySQL Configurator

The MSI copies files into C:\Program Files\MySQL\MySQL Server 9.7\. MySQL Configurator, launched at the end of the MSI, initializes the data directory, writes my.ini, registers the service and sets the root password; until it runs, nothing listens on 3306. Steps show 9.7; swap in 8.4.

  1. Install the Visual C++ Redistributable.

    Run Microsoft's vc_redist.x64.exe, or let winget do it. "Already installed" is fine.

    PowerShell
    # One-time prerequisite for the server and for Workbench
    winget install -e --id Microsoft.VCRedist.2015+.x64
  2. Download the server MSI.

    Pick your version and the MSI row, and skip the login prompt.

  3. Run the MSI.

    Accept the license, pick Typical, and approve the UAC prompt. On the last page leave "Run MySQL Configurator" checked.

  4. Configurator: Type and Networking.

    Choose Development, the lightest on memory. Leave TCP/IP on Port 3306 and X Protocol Port 33060, and untick the Windows Firewall box.

  5. Configurator: Accounts and Roles.

    Type a strong root password, the only required field, and store it in your password manager. Skip "Add User".

  6. Configurator: Windows Service.

    The Windows Service Name defaults to MySQL plus the version digits: MySQL97 or MySQL84. Write it down; keep the other defaults.

  7. Configurator: File Permissions and Sample Databases.

    Accept the default permissions and tick sakila and world; chapter 6 uses them.

  8. Configurator: Apply Configuration.

    Click Execute, watch the checklist turn green, and click Finish. my.ini and data now sit in hidden C:\ProgramData\MySQL\MySQL Server 9.7\; programs in C:\Program Files\MySQL\MySQL Server 9.7\bin\.

    PowerShell
    # Is the service there and running? (use the name from the previous step)
    Get-Service MySQL97
    # Status   Name      DisplayName
    # ------   ----      -----------
    # Running  MySQL97   MySQL97
  9. Put the bin folder on your PATH.

    Nothing adds it for you, so mysql is unknown until you do. Run the lines below, then open a new terminal.

    PowerShell
    $bin = 'C:\Program Files\MySQL\MySQL Server 9.7\bin'
    $cur = [Environment]::GetEnvironmentVariable('Path', 'User')
    [Environment]::SetEnvironmentVariable('Path', "$cur;$bin", 'User')
    # setx PATH "..." also works, but it truncates the value at 1024
    # characters and can silently chop a long PATH. Prefer the lines above.
  10. Connect.

    -u root names the account, and -p with no value makes the client prompt for the password.

    PowerShell
    mysql -u root -p
    # Enter password: ********
    # Welcome to the MySQL monitor. ...
    # mysql>
    Illustration · MySQL
    SELECT VERSION();
    SHOW DATABASES;
    exit
    VERSION()
    9.7.2

    SHOW DATABASES lists the system schemas, plus sakila and world if you ticked them.

The same install with winget

winget knows these packages, but Oracle.MySQL lags at 8.4.9 and runs Configurator silently, so you never see the pages above. Take the MSI path the first time.

PowerShell
winget install -e --id Oracle.MySQL
winget install -e --id Oracle.MySQLWorkbench
# Oracle.MySQLShell is stale (8.4.5): download Shell 26.7.1 from dev.mysql.com instead

For you as a DBA

At work, scripts do this: msiexec /i mysql-9.7.2-winx64.msi /qn, then mysql_configurator.exe --console --action=configure --password=... --windows-service-name=MySQL97. Knowing the pages lets you read those scripts.

Your first ten minutes

Four things a DBA does on every new instance: stop using root, load data, find the logs, learn the on/off switch.

Make yourself an account instead of using root

root@localhost is the master key in the safe (chapter 16 resets it). Connect as yourself so logs show who did what; chapter 14 explains the host part after the @.

Illustration · MySQL
-- Run these once, connected as root
CREATE USER 'yourname'@'localhost' IDENTIFIED BY 'a long passphrase';
GRANT ALL PRIVILEGES ON *.* TO 'yourname'@'localhost' WITH GRANT OPTION;

Then stop typing the password: mysql_config_editor stores a named login in %APPDATA%\MySQL\.mylogin.cnf, and every client accepts --login-path.

PowerShell
mysql_config_editor set --login-path=local --host=localhost --user=yourname --password
# from now on:
mysql --login-path=local

Load the shop database

Every example uses the "shop" dataset in assets/sample-shop.mysql.sql. PowerShell reserves <, so redirect inside cmd, or use the client's own source command with forward slashes.

PowerShell
cmd /c "mysql --login-path=local < C:\Users\you\dba\assets\sample-shop.mysql.sql"
Illustration · MySQL
-- ...or from inside the mysql client
source C:/Users/you/dba/assets/sample-shop.mysql.sql
SELECT name, city FROM shop.customers;
namecity
AmiraDubai
BenCairo
ChloéNULL
DevRiyadh

Four rows means server, client, account and dataset all work. PostgreSQL gets the same data in chapter 5.

Where everything lives

Programs sit in Program Files; my.ini, the Data folder and the logs sit in hidden ProgramData. Never guess the paths, because the server tells you them.

Illustration · MySQL
SELECT @@datadir, @@log_error;
@@datadir@@log_error
C:\ProgramData\MySQL\MySQL Server 9.7\Data\.\YOURPC.err

Open that .err file first whenever the service refuses to start. The my.ini beside it holds the startup settings, in forward slashes.

my.ini
[mysqld]
port=3306
datadir=C:/ProgramData/MySQL/MySQL Server 9.7/Data
log-error=YOURPC.err
lower_case_table_names=1
max_connections=151

You will edit it less often than you expect: SET PERSIST writes a setting to mysqld-auto.cnf, which survives restarts and overrides my.ini (chapter 16). lower_case_table_names is 1 on Windows, fixed at initialization.

Remember

The Windows service starts mysqld.exe with the my.ini in ProgramData. When something is wrong, SELECT @@datadir, @@log_error tells you where to look.

Stop, start, restart

You restart after editing my.ini and after a patch release, and stopping disconnects every client. Three tools do the same job from an elevated window: services.msc, net stop and net start, and the PowerShell cmdlets.

PowerShell
# Elevated window. Use the service name Configurator showed you.
net stop MySQL97
net start MySQL97
Restart-Service MySQL97
Get-Service MySQL97 | Select-Object Status, StartType

Startup is not instant: InnoDB replays its redo log after an unclean shutdown, then the error log prints "ready for connections".

Ask the AI

Hand the fiddly Windows parts to an assistant: "MySQL 9.7 on Windows 11, installed with the MSI and MySQL Configurator. Give me PowerShell to check the MySQL97 service and tail the error log."

Install the clients: Workbench and MySQL Shell

You already have mysql.exe. Two more belong on day one; chapter 6 goes deep on both.

MySQL Shell 26.7.1

MySQL MySQL Shell (mysqlsh) runs SQL, JavaScript and Python, and hosts the DBA utilities: util.dumpInstance() for fast parallel backups (chapter 15) and util.checkForServerUpgrade(). Since 26.7 one Shell serves every server line, and it starts in SQL mode; \js and \sql switch language.

PowerShell
mysqlsh yourname@localhost
# MySQL  localhost:3306 ssl  SQL > SELECT COUNT(*) FROM shop.orders;
COUNT(*)
5

MySQL Workbench 26.7.0

MySQL Workbench is Oracle's graphical client: SQL editor, result grids, visual explain and administration screens. Install the MSI, then add a connection to localhost, port 3306, user yourname.

Workbench 26.7.0 is a brand new Electron application built on MySQL Shell and officially supports 8.4 LTS and newer. The old line ended with 8.0.47, now end of life.

Troubleshooting

Almost every install problem falls into one of these buckets, and the wording of the message is your clue.

SymptomLikely causeWhat to do
Service will not start; "System error 1067"Port 3306 already used by another MySQL, MariaDB, XAMPP or Docker; a datadir that does not match the real folder; a half-initialized Data folder; missing Visual C++ runtimeRead the .err file in the Data folder first. Then netstat -ano | findstr :3306 and look up the PID in Task Manager. Check that my.ini paths use forward slashes. Reinstall vc_redist.x64.exe.
"'mysql' is not recognized as the name of a cmdlet"The bin folder is not on PATH, or the terminal was opened before you added itAdd the bin folder to PATH and open a new window, or call the program by its full path in quotes.
"ERROR 1045 (28000): Access denied for user"Wrong password, or the account exists for a different host part: 'x'@'%' is not 'x'@'localhost'Connect as root and run SELECT user, host FROM mysql.user;. Fix the password with ALTER USER (chapter 14).
"ERROR 1524 (HY000): Plugin mysql_native_password is not loaded"An old driver or tool that only speaks the removed authentication pluginUpdate the client or driver. On 8.4 only, mysql_native_password=ON is a temporary bridge; 9.x has none.
From another machine: "ERROR 2003 ... (10061)" or "ERROR 1130: Host is not allowed to connect"2003: service stopped, firewall blocking 3306, or bind_address limited to 127.0.0.1. 1130: no account whose host part matches the clientCheck SELECT @@bind_address;, add the firewall rule below, and create an account with a matching host part. Never open 3306 to the internet.
Forgot the root passwordIt happens on every inherited serverStop the service and start mysqld once with --init-file containing an ALTER USER. Chapter 16 has the procedure.
"Cannot create Windows service for MySql. Error: 0"A service with that name survives from an earlier installsc delete MySQL97 from an elevated window, or choose a different service name in Configurator.
PowerShell
# Who is on port 3306?
netstat -ano | findstr :3306
# Allow inbound 3306 if you unticked the firewall option in Configurator (elevated)
New-NetFirewallRule -DisplayName "MySQL 3306" -Direction Inbound -Protocol TCP -LocalPort 3306 -Action Allow

Uninstall and upgrade

A patch upgrade (9.7.2 to the next 9.7.x, one per quarter) keeps your data: run the newer MSI over the old install, then MySQL Configurator, which restarts the service. mysqld upgrades its own system tables at startup; mysql_upgrade was removed in 8.4. Back up first (chapter 15).

To uninstall, use MySQL Configurator's remove action, which deletes the service and offers to keep the data directory, then remove MySQL Server 9.7 in Settings > Apps. It leaves the data directory, my.ini, your saved logins, the PATH entry and the firewall rule for you to sweep up. A reinstall needs an empty Data folder.

Go deeper

Quick check

1. Which is the current, Oracle-recommended way to install MySQL 8.4 or 9.7 on Windows?

The old MySQL Installer ended with 8.0. Since 8.1 each product is its own MSI, and the server MSI bundles MySQL Configurator, which initializes the data directory, writes my.ini and registers the service. Oracle's Docker images are built for Linux only. Reread "Before you start" and "Step by step".

2. Where does a Configurator install put my.ini and the data directory?

Programs go to Program Files; my.ini, the Data folder, the error log and binary logs go to C:\ProgramData\MySQL\MySQL Server X.Y\. %APPDATA%\MySQL holds your own client files, such as your saved logins and MySQL Shell's settings. SELECT @@datadir, @@log_error confirms it. Reread "Where everything lives".

3. You installed 9.7 with Configurator and accepted the defaults. Which command restarts the server?

Configurator names the service MySQL plus the version digits, so MySQL97 for 9.7 and MySQL84 for 8.4. A plain "MySQL" name only comes from a manual mysqld --install. There is no net restart and no mysqld --restart. Reread "Stop, start, restart".

4. A new terminal says "'mysql' is not recognized as the name of a cmdlet". The service is running. What is wrong?

That message comes from PowerShell, not from MySQL: it cannot find the program. Add C:\Program Files\MySQL\MySQL Server X.Y\bin to PATH and open a new window. Reread step 9 in "Step by step" and the "Troubleshooting" table.