Skip to content
Search Fedora

    Browse this documentation

    Installing MySQL on Fedora: 9.7 or 8.4, and why it listens on every interface

    Fedora offers two MySQL versions but only one at a time, and its default behaviour differs from the two databases covered earlier.

    MySQL listening everywhere versus PostgreSQL and Valkey bound to loopback

    Terminal window
    dnf list --available "mysql*server*.x86_64" 2>/dev/null | grep -E "server"
    mysql-server.x86_64 9.7.2-1.fc45 fedora
    mysql8.4-server.x86_64 8.4.11-1.fc45 fedora
    You wantInstallVersionDownload / installed
    MySQL 9.x (default)mysql-server9.7.221.7 MiB / 125.5 MiB
    MySQL 8.4 LTSmysql8.4-server8.4.1119.3 MiB / 114.4 MiB

    There is no 8.0. For 8.0 you need MySQL’s own repository or a container.

    Terminal window
    sudo dnf install mysql-server
    mysqld --version
    /usr/libexec/mysqld Ver 9.7.2 for Linux on x86_64 (Source distribution)

    Note the path: /usr/libexec/mysqld, not /usr/sbin/mysqld — the mysqld on your PATH is a wrapper.

    This is the opposite of PostgreSQL. PostgreSQL requires postgresql-setup --initdb; MySQL initializes its data directory on first start:

    Terminal window
    sudo systemctl enable --now mysqld
    systemctl is-active mysqld
    active

    Two units exist:

    Terminal window
    systemctl list-unit-files | grep mysqld
    mysqld.service disabled disabled
    [email protected] disabled disabled

    [email protected] is the multi-instance template.

    Terminal window
    sudo mysql -u root -e "select version();"
    version()
    9.7.2

    Inspect the accounts:

    Terminal window
    sudo mysql -u root -e "select user,host,plugin from mysql.user;"
    mysql.infoschema localhost caching_sha2_password
    mysql.session localhost caching_sha2_password
    mysql.sys localhost caching_sha2_password
    root localhost caching_sha2_password

    All local accounts, using caching_sha2_password (the MySQL 8 default, stronger than the old mysql_native_password).

    The difference that matters: 3306 on every interface

    Section titled “The difference that matters: 3306 on every interface”

    This is the biggest default-vs-default difference from PostgreSQL and Valkey:

    Terminal window
    ss -lntp | grep 3306
    LISTEN 0 4096 *:3306 *:*
    LISTEN 0 70 *:33060 *:*

    *:3306 is all interfaces, not loopback. Port 33060 is the X Protocol (another protocol since MySQL 8).

    Compare the three:

    ServiceDefault bindDefault auth
    PostgreSQL 18127.0.0.1:5432peer / ident, only the postgres user
    Valkey 9.1127.0.0.1:6379no password, but loopback only
    MySQL 9.7*:3306passwordless root, reachable from the network

    This lab box has a second layer — the firewall only opens:

    Terminal window
    sudo firewall-cmd --list-services
    dhcpv6-client mdns ssh

    3306 is not there, so nothing reaches it from outside. But do not rely on that: the moment someone runs firewall-cmd --add-port=3306/tcp “for convenience”, the service is exposed.

    Terminal window
    ss -lx | grep mysql
    /var/lib/mysql/mysql.sock
    /var/lib/mysql/mysqlx.sock

    The location changed. Old scripts hardcoding /var/run/mysqld/mysqld.sock will not connect — it is now under the data directory.

    ApproachHowNote
    multi-instance[email protected] with distinct datadir / port / socketsame version, several instances
    vendor repositoryMySQL’s own yum repo ships 8.0 / 8.4 / 9.xcan coexist, switch manually
    containerspodman run -d -p 3307:3306 docker.io/library/mysql:8.0easiest, version on demand

    Containers are the most direct route for multiple versions:

    Terminal window
    podman run -d --name mysql80 -p 3307:3306 \
    -e MYSQL_ROOT_PASSWORD=secret \
    docker.io/library/mysql:8.0

    Now 9.7 sits on 3306 locally and 8.0 on 3307. See Podman in practice.

    Terminal window
    sudo mysql -u root # interactive shell
    sudo mysql -u root -e "show databases;"
    sudo mysql -u root -e "create database app;"
    mysqladmin -u root status # runtime status
    sudo systemctl restart mysqld
    SymptomCause
    cannot connect after installservice not started; systemctl start mysqld
    Access denied for user 'root'a password was set; add -p
    remote 3306 unreachablefirewall does not allow it (the service itself listens everywhere)
    old script fails on the socket pathsocket is /var/lib/mysql/mysql.sock, not /run/mysqld/
    installing 8.4 alongside errorsthey conflict; use a container or the vendor repo
    mojibake with non-ASCII datacheck client charset; MySQL 8 defaults to utf8mb4