Installing MySQL 9.7 LTS Community Edition on CentOS

Installing MySQL 9.7 LTS Community Edition on CentOS

Historically installing MySQL on a RedHat Compatible Linux server was as simple as yum install mysql-server.

Today’s MySQL Oracle Linux, Red Hat Enterprise Linux, CentOS, and Fedora 9.7 instructions are not accurate mixing in 8.4 and 8.0 information, and GenAI can also mislead you for the installation process. The most notable issue that I’d like to resolve is correct GPG Key checking, currently this is disabled --nogpgcheck as 2025 key does not operate as expected.

The following is my cloud-init.yml file I use to build VMs with OrbStack . In summary:

  • Define correct yum repos
  • Install with GPG disabled
  • Enable Service
  • Set a usable (aka non-temporary) root password

cloud-init.yml

#cloud-config
# MySQL 9.7 LTS install for CentOS Stream 9 (works on aarch64/ARM64).
#
# Notes:
#  - The repo URL path is mysql-9.7-community (NOT mysql-9.7-lts-community);
#    only the repo *id* carries the -lts- label.
#  - MySQL's published GPG key file still shows expired (2025-10-22) even
#    though the key was re-extended, and the RPM-GPG-KEY-mysql-2025 URL is
#    empty. So gpgcheck is disabled here to keep an unattended boot from
#    failing. Re-enable once MySQL refreshes the published key file.

write_files:
  - path: /etc/yum.repos.d/mysql-community.repo
    permissions: '0644'
    owner: root:root
    content: |
      [mysql-9.7-lts-community]
      name=MySQL 9.7 LTS Community Server
      baseurl=https://repo.mysql.com/yum/mysql-9.7-community/el/9/$basearch/
      enabled=1
      gpgcheck=0

      [mysql-connectors-community]
      name=MySQL Connectors Community
      baseurl=https://repo.mysql.com/yum/mysql-connectors-community/el/9/$basearch/
      enabled=1
      gpgcheck=0

      [mysql-tools-community]
      name=MySQL Tools Community
      baseurl=https://repo.mysql.com/yum/mysql-tools-community/el/9/$basearch/
      enabled=1
      gpgcheck=0

runcmd:
  - dnf clean all
  - dnf install -y --nogpgcheck mysql-community-server
  - systemctl enable --now mysqld
  - mysql --version
  # Rotate the generated temporary root password to a fresh random one.
  - [ sh, -c, "OLD_PASSWD=$(grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}'); PASSWD=\"#A$(date | md5sum | cut -c1-12)\"; echo \"ALTER USER root@localhost IDENTIFIED BY '${PASSWD}';\" | mysql -uroot -p\"${OLD_PASSWD}\" --connect-expired-password; echo \"${PASSWD}\" > /root/.mysql.password; chmod 600 /root/.mysql.password" ]

Installation Demo

Full installation instructions with orb installed and using mysql97.yml

wget https://gist.githubusercontent.com/ronaldbradford/672ebd49fc0ab0a092f74bec23461ff6/raw/9424a0f8b54b5b79356182aa8f119676cf60280f/mysql97.yml
VM_NAME="centos10"
orb create centos ${VM_NAME} -c mysql97.yml
orb -m ${VM_NAME} tail /var/log/cloud-init-output.log
ssh ${VM_NAME}@orb
PASSWD=$(sudo cat /root/.mysql.password)
mysql -uroot -p${PASSWD} -e "SELECT VERSION()"
Tagged with: MySQL 9.7 Installation

Related Posts

Fixing Old Software Bugs Without Thinking

I previously came across an issue in my benchmarking work where I relied on the Latency Histogram section of sysbench output. On Linux it worked fine — I generally ran my workload there, so it never mattered.

Read more

Curating DuckDB Datasets Leveraging AI

In Curated MySQL Data Sets for Realistic Testing I described datasets assembled the manual way — download, schema, load, validate, document — over hours or days per source. This post is the follow-up I promised: what changes when AI assists the same workflow, using DuckDB as the target engine and GeoNames as the first example.

Read more

Why INSERT IGNORE should not be used

Let’s say you’re building a reference table from source data, e.g. a silver medallion table from a primary source. In this example I am using a file of random locations on the globe extracted from OpenStreetMap (OSM) as my primary source.

Read more