Databases AWS

MySQL 8.4 Enterprise Edition on Oracle Linux 9 on AWS User Guide

| Product: MySQL 8.4 Enterprise Edition on Oracle Linux 9 on AWS

Overview

This guide covers launching and using the MySQL 8.4 Enterprise Edition on Oracle Linux 9 AMI from cloudimg on Amazon EC2.

MySQL Enterprise Edition is Oracle's commercial edition of the MySQL database. This image runs MySQL Enterprise Server 8.4.13, the 8.4 long-term support (LTS) release, and includes MySQL Enterprise Backup 8.4.13 for online physical backups. The server reports itself as MySQL Enterprise Server - Commercial.

Bring your own MySQL Enterprise subscription. No MySQL Enterprise licence is included with this AMI. To use MySQL Enterprise Edition you need your own Oracle MySQL Enterprise Edition subscription (see Licensing).

Price: $0.04 per vCPU-hour, plus your AWS infrastructure charges (EC2 and EBS), the same rate on every instance type this listing offers. The charge covers what cloudimg adds: the install of MySQL Enterprise Server and MySQL Enterprise Backup from Oracle's signed RPMs, the per-instance first-boot setup (data directory, keys and root password), the localhost-only, TLS-required configuration, the metadata-service block and the patched, hardened Oracle Linux 9. No MySQL Enterprise licence is included in that price.

What the cloudimg image adds:

  • No shared or default password. The image ships MySQL installed but not initialised: there is no data directory, no root password, no server UUID and no key in the AMI. On your instance's first boot, mysql-firstboot.service initialises the instance's own data directory (which also creates its TLS certificate authority, server and client certificates and RSA key pair), generates a 32-character root password on the instance and writes it to /root/mysql-credentials.txt (root only). No two instances share a password, a key or an identity.
  • Fail closed. MySQL refuses to start until first boot has finished. If first boot cannot complete, MySQL stays stopped and the next boot tries again.
  • TLS required. Every TCP connection must use TLS 1.2 or 1.3 (require_secure_transport=ON); a client that tries without TLS is refused. Local connections over the Unix socket stay allowed.
  • Ports 3306 and 33060 closed by default. MySQL listens on 127.0.0.1:3306 and the X Protocol on 127.0.0.1:33060 only, firewalld allows SSH only, and the security group opens SSH only. You reach the database through an SSH tunnel, or open it on purpose (see Connect from other hosts).
  • No metadata access for the database. An nftables rule refuses every connection from the mysql account to the EC2 instance metadata service, mysqld.service denies the metadata addresses in its own cgroup as well, and the AMI requires IMDSv2.
  • Safe defaults. LOAD DATA LOCAL is off, file import and export is confined to /var/lib/mysql-files, and no Enterprise plugin is enabled until you turn it on.
  • Oracle Linux 9.8 with the Unbreakable Enterprise Kernel, fully patched at build time, SELinux enforcing, key-only SSH as ec2-user with root login disabled, Amazon Time Sync, and dnf-automatic applying security updates on your instance. Oracle Linux's own community MySQL and MariaDB packages are excluded in /etc/dnf/dnf.conf, so a dnf update never replaces the Enterprise server.

What is on the image: MySQL Enterprise Server 8.4.13 (mysql-commercial-server, -client, -client-plugins, -common, -libs, -icu-data-files) and MySQL Enterprise Backup 8.4.13 (mysql-commercial-backup), installed from Oracle's own RPMs with every signature checked against Oracle's MySQL release key; cloud-init and the AWS Systems Manager agent.

Default user: ec2-user · Architecture: x86_64 · Recommended instance type: m5.large

Licensing

No MySQL Enterprise licence is included with the AMI and none is sold with it. MySQL Enterprise Edition is Oracle commercial software: before you use it you must hold your own Oracle MySQL Enterprise Edition subscription that covers the instance. The $0.04 per vCPU-hour charge covers what cloudimg adds (the install of MySQL Enterprise Server and MySQL Enterprise Backup from Oracle's signed RPMs, the per-instance first-boot setup (data directory, keys and root password), the localhost-only, TLS-required configuration, the metadata-service block and the patched, hardened Oracle Linux 9) and no MySQL Enterprise licence. Oracle's licence text is on the instance at /usr/share/doc/mysql-commercial-server/LICENSE. Subscription and licensing questions go to Oracle.

Prerequisites

  • An AWS account subscribed to the listing, an EC2 key pair and a VPC subnet.
  • A security group that allows TCP 22 (SSH) from your admin network. Do not open 3306: MySQL listens on the loopback address only.
  • An Oracle MySQL Enterprise Edition subscription, as described under Licensing.

Step 1: Launch the instance

In the AWS Marketplace listing choose Continue to Subscribe, then Continue to Configuration, pick your Region, then Launch through EC2. Choose m5.large or larger, your key pair and a security group as above.

With the AWS CLI (replace the values in angle brackets):

aws ec2 run-instances --region <region> --image-id <ami-id-from-the-listing> \
  --instance-type m5.large --key-name <your-key-pair> \
  --security-group-ids <your-security-group> --subnet-id <your-subnet> \
  --metadata-options HttpTokens=required,HttpEndpoint=enabled \
  --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=mysql-enterprise-8-4}]'

First boot takes about a minute after the instance starts: it initialises the data directory and sets the root password. Until it finishes, systemctl is-active mysql-firstboot reports activating and /root/mysql-credentials.txt holds a placeholder. Later boots start MySQL in seconds.

Step 2: Connect to your instance

Version SSH user
MySQL 8.4 Enterprise Edition on Oracle Linux 9 ec2-user
ssh -i <your-key.pem> ec2-user@<public-ip>

After you log in, the system shows Oracle Linux 9.8 on the Unbreakable Enterprise Kernel with SELinux enforcing:

cat /etc/oracle-release; uname -r; getenforce
Oracle Linux Server release 9.8
6.12.0-208.112.5.2.el9uek.x86_64
Enforcing

Step 3: Check the service

The metadata block, the first-boot service and MySQL all report active:

systemctl is-active cloudimg-mysql-imds-block mysql-firstboot mysqld
active
active
active

Check what is listening. MySQL listens on the loopback address only: 3306 is the classic MySQL protocol and 33060 is the X Protocol (MySQL Shell and the document store). Only SSH listens on the network:

sudo ss -Htlnp | awk '{print $4, $6}' | sed 's/,pid=[0-9]*,fd=[0-9]*//g' | sort -u
0.0.0.0:22 users:(("sshd"))
127.0.0.1:33060 users:(("mysqld"))
127.0.0.1:3306 users:(("mysqld"))
[::]:22 users:(("sshd"))

Step 4: Get your root password

The credentials file is readable only by root. List the setting names it holds:

sudo ls -l /root/mysql-credentials.txt /root/.my.cnf
sudo grep -oE '^[A-Z_]+=' /root/mysql-credentials.txt
-rw-------. 1 root root 192 Nov 15 04:10 /root/.my.cnf
-rw-------. 1 root root 667 Nov 15 04:10 /root/mysql-credentials.txt
MYSQL_ROOT_USER=
MYSQL_ROOT_PASSWORD=
MYSQL_HOST=
MYSQL_PORT=
MYSQL_TLS_CA=

Read the whole file with sudo cat /root/mysql-credentials.txt and store the password in your password manager. It is unique to this instance.

First boot also writes the same password to /root/.my.cnf (root only), the standard MySQL client options file, so sudo mysql opens a root session without typing it. Never pass the password on the command line with -p<password>: it would land in your shell history and the process list. Delete /root/.my.cnf if you prefer to type the password each time (mysql -u root -p prompts for it).

Step 5: Connect with the mysql client

sudo mysql -t -e "SELECT VERSION() AS version, @@version_comment AS edition, CURRENT_USER() AS user"
+-------------------+--------------------------------------+----------------+
| version           | edition                              | user           |
+-------------------+--------------------------------------+----------------+
| 8.4.13-commercial | MySQL Enterprise Server - Commercial | root@localhost |
+-------------------+--------------------------------------+----------------+

Step 6: Confirm TLS is required

Over TCP, MySQL requires TLS. This connection to 127.0.0.1 verifies the server against the instance's own certificate authority (/var/lib/mysql/ca.pem):

sudo mysql -h 127.0.0.1 --ssl-mode=VERIFY_CA --ssl-ca=/var/lib/mysql/ca.pem -t -e "SELECT CURRENT_USER() AS user; SHOW SESSION STATUS WHERE Variable_name IN ('Ssl_version','Ssl_cipher')"
+----------------+
| user           |
+----------------+
| root@localhost |
+----------------+
+---------------+------------------------+
| Variable_name | Value                  |
+---------------+------------------------+
| Ssl_cipher    | TLS_AES_128_GCM_SHA256 |
| Ssl_version   | TLSv1.3                |
+---------------+------------------------+

A client that tries TCP without TLS is refused (the || true only keeps the refused command's exit code out of your shell):

sudo mysql -h 127.0.0.1 --ssl-mode=DISABLED -e 'SELECT 1' 2>&1 | grep -o 'Connections using insecure transport are prohibited.*' || true
Connections using insecure transport are prohibited while --require_secure_transport=ON.

The certificates were created by MySQL on this instance's first boot:

sudo openssl x509 -in /var/lib/mysql/server-cert.pem -noout -subject -issuer -startdate -enddate
sudo openssl x509 -in /var/lib/mysql/ca.pem -noout -fingerprint -sha256
subject=CN=MySQL_Server_8.4.13_Auto_Generated_Server_Certificate
issuer=CN=MySQL_Server_8.4.13_Auto_Generated_CA_Certificate
notBefore=Nov 15 04:10:19 2026 GMT
notAfter=Nov 12 04:10:19 2036 GMT
sha256 Fingerprint=29:B7:15:D4:BE:2B:06:1E:2B:72:5A:B9:B9:3B:C2:D5:28:02:47:2F:49:7C:57:B5:99:7D:03:9F:C6:8A:05:D9

To verify the server from a client, copy /var/lib/mysql/ca.pem (the public CA certificate, never ca-key.pem) to the client and connect with --ssl-mode=VERIFY_CA --ssl-ca=ca.pem. The certificate names are MySQL's own (MySQL_Server_8.4.13_Auto_Generated_...), so VERIFY_IDENTITY needs a certificate you issue for your host name: put it in /etc/my.cnf.d/ as ssl_ca, ssl_cert and ssl_key, then run ALTER INSTANCE RELOAD TLS.

Step 7: Run SQL

Create a database, write a row, read it back and drop the database:

sudo mysql -t -e "CREATE DATABASE demo; CREATE TABLE demo.notes (id INT AUTO_INCREMENT PRIMARY KEY, body VARCHAR(200) NOT NULL); INSERT INTO demo.notes (body) VALUES ('hello from MySQL 8.4 Enterprise Edition'); SELECT id, body FROM demo.notes; DROP DATABASE demo;"
+----+-----------------------------------------+
| id | body                                    |
+----+-----------------------------------------+
|  1 | hello from MySQL 8.4 Enterprise Edition |
+----+-----------------------------------------+

For an application, create its own database and account instead of using root. Run this in an interactive session (sudo mysql), choosing your own strong password:

CREATE DATABASE appdb;
CREATE USER 'appuser'@'localhost' IDENTIFIED BY '<a-strong-password>';
GRANT ALL PRIVILEGES ON appdb.* TO 'appuser'@'localhost';

Use 'appuser'@'localhost' for applications on the instance and for SSH tunnels (a tunnelled connection arrives from 127.0.0.1). For hosts in your VPC see Step 8, and add REQUIRE SSL if you like (TLS is already required for every TCP connection).

Step 8: Connect from other hosts

The safest way to use MySQL Workbench, MySQL Shell or an application on your workstation is an SSH tunnel. Ports 3306 and 33060 stay closed to the network:

ssh -i <your-key.pem> -N -L 3306:127.0.0.1:3306 ec2-user@<public-ip>

Then connect your client to 127.0.0.1:3306 as root (or your application account) with TLS on (--ssl-mode=REQUIRED, or VERIFY_CA with the instance's ca.pem from Step 6). For the X Protocol, tunnel 33060 the same way.

To open port 3306 deliberately, for applications on other hosts in your VPC: listen on the network, allow the port in firewalld, and allow TCP 3306 in the security group from those hosts' CIDRs only, never from 0.0.0.0/0. Then create an account for those hosts:

sudo sed -i 's/^bind-address = 127.0.0.1$/bind-address = 0.0.0.0/' /etc/my.cnf.d/cloudimg.cnf
sudo systemctl restart mysqld
sudo firewall-cmd --permanent --zone=public --add-port=3306/tcp && sudo firewall-cmd --reload
aws ec2 authorize-security-group-ingress --group-id <your-security-group> --protocol tcp --port 3306 --cidr <app-subnet-cidr>
CREATE USER 'appuser'@'10.0.1.%' IDENTIFIED BY '<a-strong-password>' REQUIRE SSL;
GRANT ALL PRIVILEGES ON appdb.* TO 'appuser'@'10.0.1.%';

TLS stays required. To close it again, set bind-address = 127.0.0.1 back, restart MySQL, remove the firewalld port (sudo firewall-cmd --permanent --zone=public --remove-port=3306/tcp && sudo firewall-cmd --reload) and remove the security group rule.

Security details

Network and TLS settings, as MySQL reports them:

sudo mysql -t -e "SELECT @@bind_address, @@mysqlx_bind_address, @@require_secure_transport, @@tls_version, @@local_infile"
+----------------+-----------------------+----------------------------+-----------------+----------------+
| @@bind_address | @@mysqlx_bind_address | @@require_secure_transport | @@tls_version   | @@local_infile |
+----------------+-----------------------+----------------------------+-----------------+----------------+
| 127.0.0.1      | 127.0.0.1             |                          1 | TLSv1.2,TLSv1.3 |              0 |
+----------------+-----------------------+----------------------------+-----------------+----------------+

The metadata block is an nftables table that rejects every packet from the mysql account (MySQL runs as that account) to the EC2 metadata addresses; nft prints the account by its numeric uid (id -u mysql). As mysql the metadata service does not answer (000); as root it does (200):

sudo nft list table inet cloudimg_mysql_imds
sudo runuser -u mysql -- curl -s -m 5 -o /dev/null -w 'as mysql: %{http_code}\n' -X PUT -H 'X-aws-ec2-metadata-token-ttl-seconds: 60' http://169.254.169.254/latest/api/token
sudo curl -s -m 5 -o /dev/null -w 'as root: %{http_code}\n' -X PUT -H 'X-aws-ec2-metadata-token-ttl-seconds: 60' http://169.254.169.254/latest/api/token
table inet cloudimg_mysql_imds {
    chain output {
        type filter hook output priority filter; policy accept;
        meta skuid 27 ip daddr { 168.63.129.16, 169.254.169.254 } counter packets 2 bytes 120 reject with icmp port-unreachable
        meta skuid 27 ip6 daddr fd00:ec2::254 counter packets 0 bytes 0 reject with icmpv6 port-unreachable
    }
}
as mysql: 000
as root: 200

mysqld.service also denies the metadata addresses inside its own cgroup, which systemd enforces on Oracle Linux 9:

systemctl show -p IPAddressDeny mysqld
IPAddressDeny=fd00:ec2::254/128 169.254.169.254/32 168.63.129.16/32

firewalld allows SSH only, and connections to 3306 and 33060 on the instance's private address are refused:

sudo firewall-cmd --list-services
for p in 3306 33060; do timeout 3 bash -c "exec 3<>/dev/tcp/$(hostname -I | awk '{print $1}')/$p" 2>/dev/null && echo "$p open" || echo "$p refused"; done
dhcpv6-client ssh
3306 refused
33060 refused
  • First boot (/usr/local/sbin/mysql-firstboot.sh) runs mysqld --initialize-insecure as the mysql account, generates the root password into a root-only file in memory, and sets it while MySQL runs with networking off (--skip-networking), passing it through a temporary file readable only by mysql, never on a command line and never into the binary log. It then checks the version, that the password works over the socket and over TLS, that a wrong password and a connection without TLS are refused, that only the system accounts and root exist, that MySQL listens on localhost only and that the mysql account cannot reach the metadata service, before it writes the credentials file. Its log is journalctl -u mysql-firstboot.
  • Start gate. mysqld.service has a drop-in, /etc/systemd/system/mysqld.service.d/50-cloudimg.conf, that requires cloudimg-mysql-imds-block.service and refuses to start unless the metadata block is loaded and first boot has written /var/lib/cloudimg/mysql-ready. The gate runs before Oracle's own mysqld_pre_systemd.
  • Configuration is /etc/my.cnf (Oracle's, with datadir=/var/lib/mysql and the error log /var/log/mysqld.log) plus cloudimg's /etc/my.cnf.d/cloudimg.cnf. Put your own settings in another file under /etc/my.cnf.d/ so updates leave them alone.
  • Operating system. SELinux is enforcing; SSH accepts keys only and refuses root logins (/etc/ssh/sshd_config.d/00-cloudimg.conf, which sorts first); the root account is locked with no password set.

Enterprise features (optional)

The Enterprise plugins and components ship with the server and are off until you enable them. Your MySQL Enterprise subscription covers them. Installed plugins and the install scripts Oracle ships:

ls /usr/lib64/mysql/plugin | grep -E '^(audit_log|firewall|thread_pool|data_masking)\.so$'
ls /usr/share/mysql-8.4/ | grep -E '^(audit_log_filter_linux_install|linux_install_firewall)\.sql$'
audit_log.so
data_masking.so
firewall.so
thread_pool.so
audit_log_filter_linux_install.sql
linux_install_firewall.sql
  • Audit log (MySQL Enterprise Audit): sudo mysql < /usr/share/mysql-8.4/audit_log_filter_linux_install.sql, then define filters with audit_log_filter_set_filter() and audit_log_filter_set_user(). The log is written to the data directory (audit.log).
  • Thread pool (MySQL Enterprise Thread Pool): add plugin-load-add=thread_pool.so to a file under /etc/my.cnf.d/ and restart MySQL.
  • Firewall (MySQL Enterprise Firewall): sudo mysql < /usr/share/mysql-8.4/linux_install_firewall.sql, then train and enable allowlists as in Oracle's MySQL Enterprise Firewall guide.
  • Data masking (MySQL Enterprise Data Masking): sudo mysql < /usr/share/mysql-8.4/masking_functions_install.sql.

See Oracle's MySQL Enterprise Edition documentation for every feature.

Maintenance

Updates. The image was fully patched when it was built, and dnf-automatic installs Oracle Linux security updates every day. To check by hand:

sudo dnf -q check-update >/dev/null; echo "pending updates: $?"
sudo dnf -q updateinfo list --security | wc -l
pending updates: 0
0

0 and 0 mean nothing is pending (dnf check-update exits 100 when updates are available). MySQL Enterprise updates are not in the Oracle Linux repositories: download the newer MySQL Commercial Server RPM bundle for Oracle Linux / RHEL 9 with your subscription from My Oracle Support or the Oracle Software Delivery Cloud, check its signatures and upgrade in place:

rpm -K mysql-commercial-*.rpm
sudo dnf upgrade ./mysql-commercial-server-*.rpm ./mysql-commercial-client-*.rpm ./mysql-commercial-client-plugins-*.rpm ./mysql-commercial-common-*.rpm ./mysql-commercial-libs-*.rpm ./mysql-commercial-icu-data-files-*.rpm ./mysql-commercial-backup-*.rpm

Oracle Linux's own community MySQL and MariaDB packages stay excluded, so dnf update never swaps your Enterprise server for them:

grep '^excludepkgs' /etc/dnf/dnf.conf
excludepkgs=mysql mysql-server mysql-common mysql-libs mysql-errmsg mysql-devel mysql-test mysql-community-* mysql-release-el9 mariadb mariadb-server mariadb-server-* mariadb-common mariadb-errmsg mariadb-backup

Backups. MySQL Enterprise Backup takes online physical backups. Check the version, then back up to a directory on a volume with enough space and copy the result off the instance (for example to Amazon S3):

mysqlbackup --version 2>&1 | grep -m1 'MySQL Enterprise Backup'
MySQL Enterprise Backup  Ver 8.4.13-commercial for Linux on x86_64 (MySQL Enterprise - Commercial)
sudo mkdir -p /var/backups/mysql
sudo mysqlbackup --defaults-file=/root/.my.cnf --backup-dir=/var/backups/mysql/full-$(date +%F) backup-and-apply-log

For a logical backup of one database use sudo mysqldump --single-transaction --routines --triggers appdb > appdb.sql. Take EBS snapshots of the volume as a second layer.

Change the root password. Connect with sudo mysql and run ALTER USER 'root'@'localhost' IDENTIFIED BY '<new-password>';, then update /root/mysql-credentials.txt and /root/.my.cnf.

Memory. MySQL's defaults are small (a 128 MB InnoDB buffer pool). For a dedicated database server, set innodb_buffer_pool_size to about half to three quarters of the instance's memory in a file under /etc/my.cnf.d/, for example innodb_buffer_pool_size = 4G on an 8 GiB m5.large, then sudo systemctl restart mysqld.

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 Enterprise subscription and licensing questions go to Oracle.

MySQL and Oracle are registered trademarks of Oracle and/or its affiliates. cloudimg is not affiliated with or endorsed by Oracle.