MySQLWindowsDatabase5 min read

Install MySQL on Windows Server

Install MySQL on Windows Server, configure the service, and create databases and users.


MySQL runs natively on Windows Server as a Windows service. This guide covers installation using the MSI installer.

Step 1 — Download MySQL Installer

Download the MySQL MSI installer from the official website or use PowerShell:

powershell
# Download MySQL Community Server MSI
Invoke-WebRequest -Uri "https://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-8.0.36.0.msi" -OutFile "C:\temp\mysql-installer.msi"

Step 2 — Run the installer

powershell
msiexec /i "C:\temp\mysql-installer.msi" /quiet

Or run the MSI interactively and select:

  • Setup Type: Server only
  • Config Type: Server Computer
  • Authentication: Use Strong Password Encryption
  • Set the root password

Step 3 — Verify the service

powershell
Get-Service MySQL*

The MySQL service should be running.

Step 4 — Add MySQL to PATH

powershell
$mysqlPath = "C:\Program Files\MySQL\MySQL Server 8.0\bin"
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$mysqlPath", "Machine")

Restart PowerShell to apply.

Step 5 — Connect and create a database

powershell
mysql -u root -p
sql
CREATE DATABASE myapp_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'myapp_user'@'localhost' IDENTIFIED BY 'SecurePassword123!';
GRANT ALL PRIVILEGES ON myapp_db.* TO 'myapp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 6 — Allow through firewall

powershell
New-NetFirewallRule -DisplayName "MySQL" -Direction Inbound -Protocol TCP -LocalPort 3306 -Action Allow

Step 7 — Configure for remote access

Edit my.ini (usually in C:\ProgramData\MySQL\MySQL Server 8.0\):

ini
[mysqld]
bind-address = 0.0.0.0

Restart the service:

powershell
Restart-Service MySQL80

Service management

powershell
Start-Service MySQL80
Stop-Service MySQL80
Restart-Service MySQL80

Tip

For production use, run mysql_secure_installation equivalent steps: remove anonymous users, disable remote root login, and remove the test database. Adjust innodb_buffer_pool_size based on your Baires Host VPS RAM.


Was this guide helpful?