MySQL 8.4 Enterprise Edition on Windows Server 2022 on AWS User Guide
Overview
This image is MySQL 8.4 LTS Enterprise Edition (commercial, MySQL Enterprise Server 8.4.13) on Windows Server 2022 Datacenter, sold by cloudimg on AWS Marketplace as a single product. MySQL Enterprise Server is installed from Oracle's own release media (Oracle Software Delivery Cloud), on a fully patched Windows Server 2022 with the Microsoft Security Baseline applied.
Bring your own MySQL Enterprise subscription. This image includes no MySQL licence. To run MySQL Enterprise Edition you must hold your own MySQL Enterprise subscription from Oracle that covers this instance. MySQL is a trademark of Oracle; cloudimg is not affiliated with or endorsed by Oracle.
Price: $0.04 per vCPU-hour for cloudimg's image, plus your AWS infrastructure charges (EC2, which includes the Windows Server licence, and EBS). The charge covers what cloudimg adds: MySQL Enterprise Server installed from Oracle's media, the per-instance first-boot setup, the Microsoft Security Baseline, patching and the closed-by-default firewall. No MySQL Enterprise licence is included in that price.
The database is created on your instance at first boot. The image contains no database. Allow about 10 minutes after launch (up to 15) before MySQL is ready. The progress log is
C:\ProgramData\cloudimg\mysql-firstboot.log.
What cloudimg does to the image:
- No database and no password in the image. The AMI contains the MySQL Enterprise Server software only. On first boot your instance initialises its own data directory, with its own server UUID, its own TLS certificates and RSA key pair, and a random
root@localhostpassword generated on the instance. Nothing is shared between instances. - A password that only Administrators can read. The root password is written to
C:\ProgramData\cloudimg\mysql\mysql-credentials.txt, which only the Administrators group and SYSTEM can open. If first boot fails, the MySQL service stays stopped and no credentials are written. - TLS on every connection. The server runs with
require_secure_transport=ON, so it refuses any TCP connection that is not encrypted. Accounts usecaching_sha2_password, MySQL 8.4's default authentication plugin. - MySQL closed to the network by default. The listing's security group opens Remote Desktop (3389) only, and the Windows Firewall has no inbound rule for MySQL (3306) or the X Protocol (33060). You open MySQL to your own application subnet when you need it (see Allow connections from your application subnet).
rootis local only. The only administrative account isroot@localhost. Create application accounts with only the privileges they need rather than opening root to the network.- Enterprise components shipped, not enabled. MySQL Enterprise Thread Pool, Audit, Firewall and the encrypted file keyring for Transparent Data Encryption ship in the server package. Enable the ones your subscription covers (see Enable the Enterprise features).
- Microsoft Security Baseline for Windows Server 2022 (Member Server), applied with Microsoft's LGPO tool and measured with HardeningKitty on a fresh instance. The report ships in
C:\ProgramData\cloudimg\baseline\. This is a measurement made with open-source tooling against Microsoft's published baseline, not an accreditation by Microsoft or any other body. - Fully patched Windows at build time. The build fails if any update is still pending or a reboot is owed.
- A unique Administrator password on every instance (Sysprep through EC2Launch v2; retrieve it with your key pair). Remote Desktop requires Network Level Authentication, and the Windows Firewall allows inbound Remote Desktop (3389) only.
- IMDSv2 only, and no build residue: build tools, installers, history and event logs are removed and free space is wiped before capture.
Connecting to your instance
Connect with Remote Desktop as the Administrator:
| Operating system variant | Remote Desktop login user |
|---|---|
| Windows Server 2022 Datacenter | Administrator |
Launch from AWS Marketplace
- Open the listing on AWS Marketplace and choose View purchase options, then Subscribe.
- Once the subscription is active, choose Launch your software.
- Choose your Region and an instance type.
m5.large(2 vCPU, 8 GiB) is the recommended starting size (t3.largeis fine for development and testing); use a larger instance for production workloads, and make sure your MySQL Enterprise subscription covers the size you run. - Choose a key pair. You need its private key to get the Administrator password.
- Use a security group that allows RDP (TCP 3389) from your own address only. Do not open 3306 or 33060 to the internet.
- Keep the root volume on gp3; you can choose a larger volume at launch for your data.
- Optional: attach an IAM instance profile with the
AmazonSSMManagedInstanceCorepolicy, so you can reach MySQL from your workstation with Session Manager port forwarding (see Connect from your workstation) without opening any port. - Launch.
First boot: MySQL is set up on your instance
After Windows finishes its first boot, a one-time task initialises MySQL: it creates the data directory C:\ProgramData\MySQL\MySQL Server 8.4\Data (with the instance's own server UUID, TLS certificates and RSA keys), sets the random root@localhost password, writes the credentials file and sets the MySQL84 service to start automatically. Allow about 10 minutes after launch in all (up to 15). The Administrator password is ready once Windows setup has finished, so you can sign in and watch. Check progress in PowerShell:
Get-Content C:\ProgramData\cloudimg\mysql-firstboot.log -Tail 15
MySQL is ready when the ready marker exists and the service is running:
Test-Path C:\ProgramData\cloudimg\mysql-firstboot.done
Get-Service MySQL84 | Select-Object Name, Status, StartType
To follow the log live in a Remote Desktop session, run Get-Content C:\ProgramData\cloudimg\mysql-firstboot.log -Wait.
If first boot fails, the log says why, the MySQL84 service stays stopped and no credentials are written. Restart the instance to try again, or contact cloudimg support.
Get the Administrator password
In the EC2 console select the instance, choose Actions, Security, Get Windows password, upload the private key of your key pair and choose Decrypt password. Or with the AWS CLI on your workstation:
aws ec2 get-password-data --region <region> --instance-id <instance-id> \
--priv-launch-key ~/.ssh/my-key-pair.pem --query PasswordData --output text
An empty result means Windows has not finished setting the password yet; try again a minute later.
Connect over Remote Desktop
Connect to the instance's public DNS name or IP address on port 3389 with a Remote Desktop client that supports Network Level Authentication (Microsoft Remote Desktop on Windows and macOS, FreeRDP on Linux), as Administrator with the password from the previous step. Each instance generates its own Remote Desktop certificate, so your client asks you to trust it on first connection.
Read your root password
Open an elevated PowerShell in the Remote Desktop session and read the credentials file:
Get-Content C:\ProgramData\cloudimg\mysql\mysql-credentials.txt
It holds the root@localhost password generated on this instance. Store it in your password manager. If you copy it anywhere else, change it (see Change the root password).
Connect with the mysql client on the instance
The MySQL bin folder, C:\Program Files\MySQL\MySQL Server 8.4\bin, is on the system PATH. In PowerShell, connect as root; the client prompts for the password, so it never appears on the command line:
mysql -u root -p
Check the server, its edition and the connection's encryption:
SELECT @@version, @@version_comment, @@server_uuid, @@require_secure_transport;
SHOW SESSION STATUS LIKE 'Ssl_cipher';
@@version_comment names MySQL Enterprise Server, @@server_uuid is your instance's own, and Ssl_cipher shows the TLS cipher of your session (the client negotiates TLS by default, and the server refuses unencrypted TCP connections).
Create application users
root exists for localhost only. Do not open it to the network: create a database and an account for each application with only the privileges it needs. Replace 10.0.1.% with your application subnet:
CREATE DATABASE appdb;
CREATE USER 'appuser'@'10.0.1.%' IDENTIFIED BY '<a strong password>' REQUIRE SSL;
GRANT SELECT, INSERT, UPDATE, DELETE ON appdb.* TO 'appuser'@'10.0.1.%';
New accounts use caching_sha2_password. MySQL 8.4 does not load the older mysql_native_password plugin by default, so use a client or connector that supports caching_sha2_password (every current MySQL connector does).
The MySQL service and files
The Windows service MySQL84 runs the server and starts automatically:
Get-Service MySQL84 | Select-Object Name, Status, StartType
Get-NetTCPConnection -State Listen -LocalPort 3306, 33060 | Select-Object LocalAddress, LocalPort, OwningProcess
To stop and start MySQL cleanly:
Stop-Service MySQL84
Start-Service MySQL84
| Item | Location |
|---|---|
Binaries (mysqld.exe, mysql.exe, mysqldump.exe) |
C:\Program Files\MySQL\MySQL Server 8.4\bin |
| Option file | C:\ProgramData\MySQL\MySQL Server 8.4\my.ini |
| Data directory, error log, TLS certificates | C:\ProgramData\MySQL\MySQL Server 8.4\Data |
| SQL scripts (Audit and Firewall installers) | C:\Program Files\MySQL\MySQL Server 8.4\share |
| First boot log and ready marker | C:\ProgramData\cloudimg\mysql-firstboot.log, C:\ProgramData\cloudimg\mysql-firstboot.done |
| Root credentials | C:\ProgramData\cloudimg\mysql\mysql-credentials.txt |
| Port | Protocol | Open by default |
|---|---|---|
| 3306 | MySQL classic protocol (TLS required) | No: no Windows Firewall rule, not in the security group |
| 33060 | MySQL X Protocol (TLS required) | No: no Windows Firewall rule, not in the security group |
| 3389 | Remote Desktop | Yes, in the security group and the Windows Firewall |
After you edit my.ini (open it in Notepad started as administrator), restart the service with Restart-Service MySQL84. If the service does not start, the reason is in the error log in the data directory (mysqld.err).
Connect from your workstation
The safest way to use a client on your workstation (MySQL Workbench, MySQL Shell, an application under development) is AWS Systems Manager Session Manager port forwarding, which needs no inbound port at all. With the instance profile from the launch step and the Session Manager plugin installed on your workstation:
aws ssm start-session --region <region> --target <instance-id> \
--document-name AWS-StartPortForwardingSession \
--parameters portNumber=3306,localPortNumber=3306
Leave it running and connect your client to 127.0.0.1:3306. The connection is still TLS encrypted end to end by MySQL.
Allow connections from your application subnet
If your applications connect to MySQL directly, open port 3306 to your application network only, in both the Windows Firewall and the security group:
- Allow TCP 3306 in the Windows Firewall from your application subnet only (replace
10.0.1.0/24with yours):
powershell
New-NetFirewallRule -DisplayName 'MySQL 3306 from app subnet' -Direction Inbound -Protocol TCP -LocalPort 3306 -RemoteAddress 10.0.1.0/24 -Action Allow
Add a second rule for 33060 the same way only if your applications use the X Protocol (MySQL Shell, X DevAPI connectors).
2. Add an inbound rule for TCP 3306 from the same source range (or from your application's security group) to the instance's security group.
3. Never open 3306 or 33060 to 0.0.0.0/0.
Clients must use TLS (the server refuses anything else). To have a client also verify the server's certificate, copy ca.pem from the data directory to the client and connect with --ssl-mode=VERIFY_CA --ssl-ca=ca.pem (or the equivalent connector option). The certificate authority is the instance's own, created at first boot; to use certificates from your own CA instead, set ssl_ca, ssl_cert and ssl_key in my.ini as Oracle's Configuring MySQL to Use Encrypted Connections describes.
Change the root password
Connect with mysql -u root -p and run:
ALTER USER 'root'@'localhost' IDENTIFIED BY '<new password>';
Then update or delete C:\ProgramData\cloudimg\mysql\mysql-credentials.txt.
Enable the Enterprise features
These MySQL Enterprise components ship in the server package and are not enabled in the image. Enable only what your MySQL Enterprise subscription covers. Take a backup before you change a production server, and run the commands from an elevated PowerShell on the instance. The mysql -u root -p commands prompt for the root password.
MySQL Enterprise Thread Pool
The thread pool is loaded at server start. Add this line to the [mysqld] section of my.ini:
plugin-load-add=thread_pool.dll
Restart the service and check that the plugin is active and the server uses it:
Restart-Service MySQL84
mysql -u root -p -e "SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE 'thread%'; SHOW VARIABLES LIKE 'thread_handling';"
thread_pool should be ACTIVE and thread_handling should be loaded-dynamically. Tuning options are in Oracle's MySQL Enterprise Thread Pool documentation.
MySQL Enterprise Audit
Run Oracle's Windows installer script for the audit log plugin, its tables and functions, into the mysql system database:
cmd /c 'mysql -u root -p -D mysql < "C:\Program Files\MySQL\MySQL Server 8.4\share\audit_log_filter_win_install.sql"'
mysql -u root -p -e "SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE 'audit%';"
audit_log should be ACTIVE. Audit filtering is rule based, and nothing is logged until you assign a filter. To log every event for every account:
SELECT audit_log_filter_set_filter('log_all', '{ "filter": { "log": true } }');
SELECT audit_log_filter_set_user('%', 'log_all');
The audit log is written to the data directory. To stop the plugin being unloaded at runtime, add audit-log=FORCE_PLUS_PERMANENT to the [mysqld] section of my.ini. Filters, log format and rotation are covered in Oracle's MySQL Enterprise Audit documentation.
MySQL Enterprise Firewall
Run Oracle's Windows installer script for the firewall plugins, tables and stored procedures:
cmd /c 'mysql -u root -p -D mysql < "C:\Program Files\MySQL\MySQL Server 8.4\share\win_install_firewall.sql"'
mysql -u root -p -e "SHOW GLOBAL VARIABLES LIKE 'mysql_firewall_mode';"
mysql_firewall_mode should be ON. The firewall then protects only the profiles you register: train a profile in recording mode on your application's normal statements, then switch it to protecting mode. Oracle prefers a dedicated schema for the firewall tables over the mysql system database; both, and profile training, are in Oracle's MySQL Enterprise Firewall documentation.
Transparent Data Encryption with the encrypted file keyring
InnoDB data-at-rest encryption needs a keyring. component_keyring_encrypted_file keeps the master key in a password-protected file. Keyring components are loaded through a manifest file mysqld.my next to mysqld.exe, and read their settings from component_keyring_encrypted_file.cnf in the plugin directory. Only one keyring component or plugin may be enabled at a time.
- Find the plugin directory and the account the service runs as:
powershell
mysql -u root -p -e "SELECT @@plugin_dir;"
(Get-CimInstance Win32_Service -Filter "Name='MySQL84'").StartName
- Create the keyring folder (outside the data directory and outside
C:\Program Files), the component configuration with a random keyring password, and the manifest. Set$pluginto the plugin directory and$svcto the service account from step 1:
```powershell $plugin = 'C:\Program Files\MySQL\MySQL Server 8.4\lib\plugin' $svc = 'NT SERVICE\MySQL84' $keydir = 'C:\ProgramData\MySQL\keyring' New-Item -ItemType Directory -Path $keydir -Force | Out-Null icacls $keydir /inheritance:r /grant:r 'Administrators:(OI)(CI)F' 'SYSTEM:(OI)(CI)F' "${svc}:(OI)(CI)M" $bytes = New-Object byte[] 32
$cnf = Join-Path $plugin 'component_keyring_encrypted_file.cnf' @{ path = "$keydir\component_keyring_encrypted_file.keys"; password = [Convert]::ToBase64String($bytes); read_only = $false } | ConvertTo-Json | Set-Content -Encoding ascii $cnf icacls $cnf /inheritance:r /grant:r 'Administrators:F' 'SYSTEM:F' "${svc}:R" '{ "components": "file://component_keyring_encrypted_file" }' | Set-Content -Encoding ascii 'C:\Program Files\MySQL\MySQL Server 8.4\bin\mysqld.my' Remove-Variable bytes ```
- Restart the service and check the keyring:
powershell
Restart-Service MySQL84
mysql -u root -p -e "SELECT * FROM performance_schema.keyring_component_status;"
Component_status should be Active. If it is Disabled, the error log says why.
- Encrypt tables:
ALTER TABLE appdb.mytable ENCRYPTION='Y';for an existing table, orSET PERSIST default_table_encryption = ON;so that new schemas and tables are encrypted by default.
Back up the keyring file and component_keyring_encrypted_file.cnf (its password) securely and separately from your database backups. Without them, encrypted tables cannot be read. Key rotation (ALTER INSTANCE ROTATE INNODB MASTER KEY) and encrypting the redo and undo logs are covered in Oracle's InnoDB Data-at-Rest Encryption and encrypted file keyring documentation.
MySQL Enterprise Backup is not in the image
MySQL Enterprise Backup (mysqlbackup) is a separate Oracle download and is not installed in this image. If your subscription includes it, download it from Oracle with your own account and install it on the instance.
View the baseline report
Everything the build measured ships in C:\ProgramData\cloudimg\baseline\:
| File | What it is |
|---|---|
baseline-report.html |
Every rule audited, its result and the recommended value; waived rules marked |
hardeningkitty-report.csv |
The raw HardeningKitty audit |
baseline-summary.json |
Rules audited, waived, scored and passed, the pass rate and threshold |
waivers.txt / waivers.json |
The waived rules and why |
tool-versions.json |
The baseline, LGPO, HardeningKitty and MySQL media versions and SHA-256 values |
Get-Content C:\ProgramData\cloudimg\baseline\baseline-summary.json | ConvertFrom-Json |
Select-Object profile, audited, waived, scored, pass, fail, ratePct, thresholdPct, evaluatedAt
Open baseline-report.html in a browser on the instance, or copy it to your workstation.
Re-run the audit yourself
HardeningKitty v.0.9.4 stays in the image. Run it in an elevated PowerShell; it only reads settings and takes a minute or two:
$hk = 'C:\ProgramData\cloudimg\tools\HardeningKitty-0.9.4'
Import-Module "$hk\HardeningKitty.psm1" -Force
$list = "$hk\lists\finding_list_msft_security_baseline_windows_server_2022_21h2_member_machine.csv"
$csv = Join-Path $env:TEMP 'hardeningkitty-now.csv'
Remove-Item $csv -ErrorAction SilentlyContinue
$null = Invoke-HardeningKitty -Mode Audit -FileFindingList $list -Report -ReportFile $csv -SkipMachineInformation *>&1
$waived = (Get-Content -Raw C:\ProgramData\cloudimg\baseline\waivers.json | ConvertFrom-Json).waivers.id
$scored = @(Import-Csv $csv | Where-Object { $waived -notcontains $_.ID })
$pass = @($scored | Where-Object { $_.Severity -eq 'Passed' }).Count
"{0} of {1} scored rules pass ({2:N1}%)" -f $pass, $scored.Count, (100 * $pass / $scored.Count)
$scored | Where-Object { $_.Severity -ne 'Passed' } | Select-Object ID, Name, Result, Recommended
Waived rules
These rules are set differently on purpose. Each one is in waivers.txt with its reason:
| ID | Rule | Set to | Why |
|---|---|---|---|
| 10311 | Deny access to this computer from the network | Guests | The baseline denies network logon to local administrators. Remote Desktop with Network Level Authentication checks the Administrator's password with a network logon first, so the EC2 Administrator could not sign in. |
| 10312 | Deny log on through Remote Desktop Services | Guests | The baseline denies Remote Desktop to every local account. On a stand-alone EC2 instance the local Administrator is the only way in. |
| 10672-10677 | Device Guard: Virtualization Based Security and Credential Guard (6 rules) | Not configured | Credential Guard needs UEFI Secure Boot. This image boots in legacy BIOS mode on EC2, so the policy could not run and a "pass" would be misleading. |
Windows Firewall
Every firewall profile is on with inbound traffic blocked unless a rule allows it. The only inbound rules enabled are Remote Desktop (3389, TCP and UDP) and core networking (ICMP, DHCP); there is no rule for 3306 or 33060 until you add one:
Get-NetFirewallRule -Direction Inbound -Enabled True -Action Allow |
Select-Object DisplayGroup, DisplayName, Profile | Sort-Object DisplayGroup, DisplayName
Get-NetFirewallProfile | Select-Object Name, Enabled, DefaultInboundAction
Instance metadata (IMDSv2)
The image requires IMDSv2: a request to the instance metadata service without a session token is refused. Windows, EC2Launch v2 and the SSM agent all use IMDSv2.
Patching
Windows is fully patched when the image is built. Check for newer updates with:
$searcher = (New-Object -ComObject Microsoft.Update.Session).CreateUpdateSearcher()
$searcher.Search("IsInstalled=0 and IsHidden=0 and Type='Software'").Updates | Select-Object Title
and install them from Settings, Windows Update (or sconfig option 6). The MySQL84 service shuts down cleanly when Windows restarts.
MySQL patch releases (newer 8.4.x releases of MySQL Enterprise Server) are available only to MySQL Enterprise subscribers, so cloudimg does not apply them. Check the installed release with mysql -u root -p -e "SELECT @@version;", then download the Windows package of the newer release from Oracle with your own subscription (My Oracle Support, Patches and Updates, or Oracle Software Delivery Cloud) and follow Oracle's Upgrading MySQL and Upgrading MySQL on Windows documentation. In outline: back up first, stop MySQL84, replace the files in C:\Program Files\MySQL\MySQL Server 8.4 (your my.ini and data in C:\ProgramData are not touched; keep bin\mysqld.my if you created it), and start the service again; the server upgrades its system tables when it starts.
Backups
Take logical backups with mysqldump (in the bin folder), or physical backups with MySQL Enterprise Backup if your subscription includes it (a separate Oracle download), and copy them off the instance, for example to Amazon S3. EBS snapshots of a running server are crash-consistent only; InnoDB recovers from them, but stop the service or use a backup tool when you need a clean copy. If you enable Transparent Data Encryption, back up the keyring file and its configuration as well.
Licensing
This image includes no MySQL licence. You bring your own MySQL Enterprise subscription from Oracle, which must cover the instance under your Oracle agreement. The cloudimg charge on AWS Marketplace ($0.04 per vCPU-hour) is for the image: the install from Oracle's media, the per-instance first-boot setup, the hardening and patching; the Windows Server licence is included in the EC2 charge. MySQL Enterprise Edition features, MySQL patch releases and MySQL Enterprise Backup come to you under your subscription with Oracle, not from cloudimg.
Support
cloudimg's support team is on hand 24 hours a day by email for this image, with a guaranteed response within 24 hours: support@cloudimg.co.uk or https://www.cloudimg.co.uk/support. MySQL licensing and subscription questions go to Oracle; Windows Server licensing questions go to AWS and Microsoft.
MySQL, Oracle and Java are registered trademarks of Oracle and/or its affiliates. Microsoft and Windows Server are trademarks of the Microsoft group of companies. cloudimg is not affiliated with or endorsed by Oracle or Microsoft.