WindowsMay 26, 2026 10 views

Installer MySQL sur un VPS Windows Server

Installer MySQL sur un VPS Windows Server

Quick Summary

To install MySQL on a Windows Server VPS in 5 steps:

1) download MySQL Installer 8.4 LTS from dev.mysql.com,

2) launch the installer in Server Only mode,

3) configure the root password and authentication caching_sha2_password,

4) check the service with Get-Service MySQL84 in PowerShell,

5) secure the installation with mysql_secure_installation. Allow 15 minutes. MySQL 8.4 LTS (current version: 8.4.9) is the recommended version for production.


Prerequisites

Before you begin, check these points on your machine:

  • Windows Server 2019 or 2022 (2022 recommended)

  • Minimum 2 GB of RAM: 4 GB recommended for real use

  • Administrator access via RDP

  • Port 3306 available (check with netstat -ano | findstr :3306)

  • .NET Framework 4.5.2+ (included in Windows Server 2019/2022)

Don't have a Windows VPS yet? Check out the OuiHeberg Windows VPS offers: available from just a few euros per month with Windows Server 2022 pre-installed.


Which version of MySQL to choose?

Since 2023, Oracle has adopted a two-branch release cycle: LTS (Long-Term Support) and Innovation (frequent updates, less stable). Here's what it looks like in May 2026:

Version

Type

Latest release

Support until

Recommended for

MySQL 8.0

Legacy

8.0.46

EOL April 2026

Urgent migration required

MySQL 8.4 LTS

LTS ✅

8.4.9

2032

Production: recommended choice

MySQL 9.7 LTS

LTS (new)

9.7.0

2032+

Production (released April 2026)

Our recommendation: MySQL 8.4.9 LTS for production.

MySQL 8.0 has reached end of life since April 2026: do not install it anymore. MySQL 9.7 LTS has just been released (April 21, 2026): it is solid but its ecosystem of tools and drivers is not yet as mature as 8.4. The 8.4 LTS remains the safest choice for a production server in 2025-2026.


Method 1: Installation via the graphical installer (GUI)

This is the simplest method. It is suitable for most cases.

Download MySQL Installer

Go to dev.mysql.com/downloads/installer/ and download MySQL Installer for Windows (file mysql-installer-community-8.4.x.msi, ~450 MB for the full version).

You can also use the web installer (~3 MB) which downloads components on the fly: convenient if you have a good connection.

Choose the installation type

Upon launch, the installer offers several profiles:

Type

What it installs

Use case

Server Only

MySQL Server only

Production VPS ✅

Developer Default

Server + Workbench + connectors

Development workstation

Full

Everything (>1 GB)

Rarely useful on a VPS

Choose "Server Only" on a VPS. There is no need to install MySQL Workbench on a server without a permanent graphical interface.

Configure the MySQL server

The wizard will ask you several important questions:

Configuration type:

  • Development Computer: MySQL uses few resources (for a dev workstation)

  • Server Computer: shares resources with other services

  • Dedicated Computer: MySQL takes the majority of RAM ✅ (recommended on a VPS dedicated to MySQL)

Port: leave 3306 by default unless there is a specific constraint.

Authentication method: choose caching_sha2_password (recommended option since MySQL 8.0). Only use mysql_native_password if you have old clients that do not support SHA-2.

Root password: choose a strong password (16+ characters, uppercase letters, numbers, special characters). Note it immediately in a password manager.

Windows Service: leave the default name (MySQL84) and check "Start the MySQL Server at System Startup".

Check the installation

Once the installation is complete, open PowerShell as an administrator:

# Check that the service is running
Get-Service MySQL84

# Expected result:
# Status   Name               DisplayName
# ------   ----               -----------
# Running  MySQL84            MySQL84

Then connect to the MySQL CLI to confirm:

cd "C:\Program Files\MySQL\MySQL Server 8.4\bin"
.\mysql.exe -u root -p

Enter your root password. If you get the prompt mysql>, the installation is successful.

-- Check the installed version
SELECT VERSION();
-- Result: 8.4.9

Method 2: Silent installation via PowerShell (advanced)

This method is ideal for automating deployments or configuring multiple VPS without a graphical interface. Everything is done in PowerShell.

# 1. Download the MySQL 8.4 LTS MSI
$url = "https://dev.mysql.com/get/Downloads/MySQL-8.4/mysql-8.4.9-winx64.msi"
$dest = "C:\Temp\mysql-8.4.9-winx64.msi"
New-Item -ItemType Directory -Force -Path "C:\Temp" | Out-Null
Invoke-WebRequest -Uri $url -OutFile $dest -UseBasicParsing

# 2. Silent installation with parameters
$arguments = @(
    "/i", $dest,
    "/qn",
    "/L*V", "C:\Temp\mysql_install.log",
    "INSTALLDIR=`"C:\Program Files\MySQL\MySQL Server 8.4\`"",
    "DATADIR=`"C:\ProgramData\MySQL\MySQL Server 8.4\Data\`"",
    "PORT=3306",
    "SERVICENAME=MySQL84",
    "NTSERVICE=1",
    "ADDLOCAL=MySQLServer"
)
Start-Process msiexec.exe -ArgumentList $arguments -Wait -NoNewWindow

# 3. Initialize the database
$mysqlBin = "C:\Program Files\MySQL\MySQL Server 8.4\bin"
& "$mysqlBin\mysqld.exe" --initialize-insecure --user=mysql

# 4. Start the service
Start-Service MySQL84

# 5. Set the root password (replace YourPassword with a strong password)
& "$mysqlBin\mysql.exe" -u root --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourPassword!';"

Write-Host "MySQL 8.4 installed successfully." -ForegroundColor Green

Post-installation verification:

Get-Service MySQL84
& "C:\Program Files\MySQL\MySQL Server 8.4\bin\mysql.exe" -u root -p -e "SELECT VERSION();"

Note: The option --initialize-insecure creates a root account without a password. The script sets it immediately after. Never leave a MySQL without a root password, even temporarily.


Configure remote access to MySQL

By default, MySQL only listens on 127.0.0.1. To connect from another server or a tool like MySQL Workbench, you need to open remote access.

Open port 3306 in the Windows firewall

# Add an inbound rule for MySQL
New-NetFirewallRule `
    -DisplayName "MySQL 3306" `
    -Direction Inbound `
    -Protocol TCP `
    -LocalPort 3306 `
    -Action Allow `
    -Profile Any

# Check the rule
Get-NetFirewallRule -DisplayName "MySQL 3306"

For more on firewall management, check out our guide on configuring the Windows Server firewall.

Create a user with remote access

Never give remote access to the root account. Create a dedicated user:

-- Connect as root first
mysql -u root -p

-- Create a remote user (replace the IP with that of your client)
CREATE USER 'myuser'@'192.168.1.100' IDENTIFIED BY 'StrongPassword!2025';

-- Or to allow all IPs (less secure)
CREATE USER 'myuser'@'%' IDENTIFIED BY 'StrongPassword!2025';

-- Grant rights on a specific database
GRANT SELECT, INSERT, UPDATE, DELETE ON mydatabase.* TO 'myuser'@'192.168.1.100';

FLUSH PRIVILEGES;

Tip: always restrict access to a specific IP rather than using the wildcard %.

Enable SSL/TLS for remote connections

MySQL 8.4 automatically generates SSL certificates on startup. Check that they are active:

SHOW VARIABLES LIKE '%ssl%';
-- have_ssl should display: YES

To enforce SSL on a remote user:

ALTER USER 'myuser'@'192.168.1.100' REQUIRE SSL;
FLUSH PRIVILEGES;

On the client side, the connection is then made with:

mysql -u myuser -p -h SERVER_IP --ssl-mode=REQUIRED

Optimize MySQL performance (my.ini)

The MySQL configuration file on Windows is located here: C:\ProgramData\MySQL\MySQL Server 8.4\my.ini

Open it with Notepad++ or PowerShell and adjust these parameters according to your available RAM:

[mysqld]
# InnoDB buffer size: the most important parameter
# Set to 70% of the available RAM for MySQL
innodb_buffer_pool_size = 2G

# Maximum number of simultaneous connections
max_connections = 150

# Size of InnoDB log files
innodb_log_file_size = 256M

# Query cache (disabled by default in 8.x, leave at 0)
query_cache_size = 0
query_cache_type = 0

# InnoDB I/O threads (= number of CPU cores)
innodb_read_io_threads = 4
innodb_write_io_threads = 4

Recommended configuration table according to VPS RAM:

VPS RAM

innodb_buffer_pool_size

max_connections

innodb_log_file_size

2 GB

1G

75

128M

4 GB

2.5G

150

256M

8 GB

5G

300

512M

16 GB

11G

500

1G

After modification, restart the service:

Restart-Service MySQL84

Secure MySQL on Windows Server

Run mysql_secure_installation

This is the first thing to do after installation:

cd "C:\Program Files\MySQL\MySQL Server 8.4\bin"
.\mysql_secure_installation.exe

The tool guides you to remove anonymous users, disable remote root login, and delete the test database. Answer Y to all questions.

The 8 essential security points

1. Remove anonymous users

DELETE FROM mysql.user WHERE User='';
FLUSH PRIVILEGES;

2. Disable remote root login

DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
FLUSH PRIVILEGES;

3. Delete the test database

DROP DATABASE IF EXISTS test;
DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';
FLUSH PRIVILEGES;

4. Use strong passwords: enable the validation policy

INSTALL PLUGIN validate_password SONAME 'validate_password.dll';
SET GLOBAL validate_password.policy = STRONG;
SET GLOBAL validate_password.length = 12;

5. Limit privileges by user

Never use GRANT ALL PRIVILEGES ON *.* TO .... Only grant the necessary rights on the relevant databases.

-- Good example
GRANT SELECT, INSERT, UPDATE ON appdb.* TO 'appuser'@'localhost';

-- Absolutely avoid
-- GRANT ALL PRIVILEGES ON *.* TO 'appuser'@'%';

6. Enable audit logs

Add to my.ini:

[mysqld]
general_log = 1
general_log_file = "C:/ProgramData/MySQL/MySQL Server 8.4/Data/mysql_general.log"
log_error = "C:/ProgramData/MySQL/MySQL Server 8.4/Data/mysql_error.log"

7. Encrypt connections (SSL/TLS)

As seen in the remote access section, enforce SSL on all users connecting from outside with REQUIRE SSL.

8. Update regularly

Check dev.mysql.com/downloads/mysql/ for new versions. Security updates are frequent: subscribe to MySQL Security Advisories.


Automate MySQL backups

Complete PowerShell script with rotation

Copy this script into C:\Scripts\mysql_backup.ps1:

# =============================================
# MySQL backup script with rotation
# To be scheduled via Task Scheduler
# =============================================

$mysqlBin    = "C:\Program Files\MySQL\MySQL Server 8.4\bin"
$backupDir   = "C:\Backups\MySQL"
$mysqlUser   = "root"
$mysqlPass   = "YourPassword!"   # Or use a .cnf file
$retention   = 7                    # Retention days

# Create the backup folder if necessary
New-Item -ItemType Directory -Force -Path $backupDir | Out-Null

# File name with timestamp
$timestamp   = Get-Date -Format "yyyy-MM-dd_HH-mm"
$backupFile  = "$backupDir\mysql_backup_$timestamp.sql"
$compressedFile = "$backupFile.gz"

# List all databases (excluding system databases)
$databases = & "$mysqlBin\mysql.exe" -u $mysqlUser -p"$mysqlPass" `
    -e "SHOW DATABASES;" --batch --skip-column-names 2>$null |
    Where-Object { $_ -notin @('information_schema','performance_schema','sys','mysql') }

# Dump each database
foreach ($db in $databases) {
    $dbFile = "$backupDir\${db}_$timestamp.sql"
    & "$mysqlBin\mysqldump.exe" `
        -u $mysqlUser -p"$mysqlPass" `
        --single-transaction `
        --routines `
        --triggers `
        --databases $db `
        --result-file=$dbFile 2>$null

    if ($LASTEXITCODE -eq 0) {
        Write-Host "✓ Backup successful: $db" -ForegroundColor Green
    } else {
        Write-Host "✗ Error on: $db" -ForegroundColor Red
    }
}

# Rotation: delete files older than $retention days
Get-ChildItem -Path $backupDir -Filter "*.sql" |
    Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-$retention) } |
    Remove-Item -Force

Write-Host "Rotation completed. Files kept: $retention days." -ForegroundColor Cyan

Schedule with Windows Task Scheduler

# Create a scheduled task: daily backup at 2 AM
$action  = New-ScheduledTaskAction `
    -Execute "PowerShell.exe" `
    -Argument "-NonInteractive -ExecutionPolicy Bypass -File C:\Scripts\mysql_backup.ps1"

$trigger = New-ScheduledTaskTrigger -Daily -At "02:00"

$settings = New-ScheduledTaskSettingsSet `
    -ExecutionTimeLimit (New-TimeSpan -Hours 1) `
    -RestartCount 3 `
    -RestartInterval (New-TimeSpan -Minutes 5)

Register-ScheduledTask `
    -TaskName "MySQL Backup Daily" `
    -Action $action `
    -Trigger $trigger `
    -Settings $settings `
    -RunLevel Highest `
    -Force

Write-Host "Scheduled task created successfully." -ForegroundColor Green

For more on the complete backup strategy for your server, check out our guide on backing up your Windows VPS.


Troubleshooting: 6 common errors

1. The MySQL service does not start

Check the error logs first:

Get-Content "C:\ProgramData\MySQL\MySQL Server 8.4\Data\[machine-name].err" -Tail 50

Common causes: port 3306 already occupied, insufficient permissions on the Data folder, malformed my.ini file.

2. Error "Access denied for user root"

If you have forgotten the root password or if authentication fails:

# Stop the service
Stop-Service MySQL84

# Start MySQL in no-authentication mode
& "C:\Program Files\MySQL\MySQL Server 8.4\bin\mysqld.exe" --skip-grant-tables --skip-networking

# In another PowerShell window, connect without a password
& "C:\Program Files\MySQL\MySQL Server 8.4\bin\mysql.exe" -u root

# Reset the password
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword!';
EXIT;

# Restart normally
Stop-Process -Name mysqld -Force
Start-Service MySQL84

3. Port 3306 is already in use

# Identify the process using port 3306
netstat -ano | findstr :3306

# Find the process name with its PID
Get-Process -Id [FOUND_PID]

Either stop the conflicting process or change the MySQL port in my.ini (port=3307).

4. Unable to connect remotely

Quick checklist:

  • Is port 3306 open in the Windows firewall? (Get-NetFirewallRule -DisplayName "MySQL 3306")

  • Is MySQL listening on 0.0.0.0? (SHOW VARIABLES LIKE 'bind_address'; should return * or 0.0.0.0)

  • Does the user have rights from the remote IP? (SELECT User, Host FROM mysql.user;)

  • Does your host/network firewall block the port?

To listen on all interfaces, add to my.ini:

[mysqld]
bind-address = 0.0.0.0

5. Forgotten root password (reset procedure)

See point 2 above: the --skip-grant-tables procedure works for both cases.

6. "Table is full" error (InnoDB)

This error occurs when innodb_buffer_pool_size is too low or the tablespace is saturated.

-- Check available space
SELECT table_schema, ROUND(SUM(data_length+index_length)/1024/1024,1) AS "Size (MB)"
FROM information_schema.tables
GROUP BY table_schema;

-- Check the size of the InnoDB tablespace
SHOW VARIABLES LIKE 'innodb_data_file_path';

Increase innodb_buffer_pool_size in my.ini according to the table in the performance section, then restart the service.


FAQ

Which version of MySQL to install on Windows Server 2022?

Install MySQL 8.4.9 LTS. This is the recommended Long-Term Support version for production in 2026-2028, with guaranteed support until 2032. MySQL 8.0 has reached end-of-life since April 2026.

Is MySQL free on Windows Server?

Yes. MySQL Community Edition is completely free under the GPL license. MySQL Enterprise Edition (paid) adds advanced monitoring, auditing, and backup tools: useful for large enterprises, but not necessary for most uses.

How to change the default MySQL port?

Edit my.ini (C:\ProgramData\MySQL\MySQL Server 8.4\my.ini) and change the line port=3306 to the desired port (e.g. port=3307). Restart the service and update the corresponding firewall rule.

MySQL or MariaDB on Windows Server?

Both are excellent choices. MySQL 8.4 LTS is more suitable if you are using Oracle tools or specific features (JSON, Group Replication). MariaDB often performs better under mixed loads and remains 100% community-driven. For a standard Windows VPS, MySQL 8.4 is the most documented and compatible choice with modern PHP/Python stacks.

How to know if MySQL is properly installed?

Two quick checks in PowerShell: Get-Service MySQL84 (the status should be Running) and mysql -u root -p -e "SELECT VERSION();" (should return 8.4.9).

Can MySQL be installed on a 2GB RAM Windows VPS?

Yes, but that is the minimum. With 2GB, set innodb_buffer_pool_size = 1G and max_connections = 75. For real production loads (several dozen simultaneous queries), 4GB of RAM is the comfortable minimum.


Useful sources