Installing MySQL or MariaDB server on a CentOS Stream, RHEL, or Fedora host gives applications and admins a local SQL service with packaged updates, predictable service management, and standard filesystem locations. That is usually cleaner than unpacking vendor tarballs by hand, especially when the host also needs routine security updates and systemd supervision.

On current Red Hat family releases, dnf pulls the server daemon, client utilities, and the matching systemd unit from the enabled repositories. MariaDB installs the mariadb.service unit and the mariadbd server binary, while distro-packaged MySQL installs the mysqld.service unit and the mysqld server binary with data stored under /var/lib/mysql.

Choose one server family before you install it, because current MariaDB and MySQL RPM sets still conflict with each other on Red Hat family systems. Package names also vary by release: RHEL 9 uses mysql-server for the default MySQL stream, RHEL 9.6 and later add a MySQL 8.4 module stream, and RHEL 10 or CentOS Stream 10 expose mysql8.4-server directly. Only open TCP port 3306 after the server is running and you have decided whether remote access is actually required.

Steps to install MySQL or MariaDB server on CentOS Stream, RHEL, and Fedora:

  1. Open a terminal session with an account that can use sudo.
  2. Refresh repository metadata and install pending system updates before adding the database server packages.
    $ sudo dnf upgrade --refresh --assumeyes
    Rocky Linux 9 - BaseOS                          6.1 MB/s | 9.1 MB     00:01
    Rocky Linux 9 - AppStream                       6.4 MB/s |  12 MB     00:01
    Rocky Linux 9 - Extras                           24 kB/s |  17 kB     00:00
    Dependencies resolved.
    ##### snipped #####
    Complete!
  3. Decide whether the host should run MariaDB or MySQL.

    Install only one server family at a time. Current distro MariaDB and MySQL packages replace some shared libraries and helper packages, so switching families is cleaner after removing the previously installed database server first.

  4. Check which server package names the current release exposes before choosing the install command.
    $ sudo dnf list --available "mysql*-server" "mariadb*-server"
    Available Packages
    mariadb-server.aarch64                    3:10.5.29-3.el9_7      appstream
    mysql-server.aarch64                      8.0.45-1.el9_7         appstream

    Current RHEL 10 and CentOS Stream 10 systems report mysql8.4-server instead of mysql-server, and current Fedora releases can expose both mysql-server and mysql8.4-server.

  5. Install the MariaDB server package when MariaDB is the chosen database.
    $ sudo dnf install --assumeyes mariadb-server
    Last metadata expiration check: 0:00:01 ago on Thu Apr  9 15:36:54 2026.
    Dependencies resolved.
    ================================================================================
     Package                     Arch     Version                  Repository  Size
    ================================================================================
    Installing:
     mariadb-server              aarch64  3:10.5.29-3.el9_7        appstream  9.3 M
    Installing dependencies:
     mariadb                     aarch64  3:10.5.29-3.el9_7        appstream  1.6 M
     mariadb-common              aarch64  3:10.5.29-3.el9_7        appstream   27 k
    ##### snipped #####
    Complete!

    RHEL 9.4 and later also provide the MariaDB 10.11 Application Stream, installable with

    $ sudo dnf module install mariadb:10.11/server

    when you need that newer stream instead of the default one.

  6. Install the distro MySQL server package when MySQL is the chosen database.
    $ sudo dnf install --assumeyes mysql-server
    Last metadata expiration check: 0:00:01 ago on Thu Apr  9 15:37:22 2026.
    Dependencies resolved.
    ================================================================================
     Package                     Arch     Version                  Repository  Size
    ================================================================================
    Installing:
     mysql-server                aarch64  8.0.45-1.el9_7           appstream   16 M
    Installing dependencies:
     mysql                       aarch64  8.0.45-1.el9_7           appstream   86 M
     mysql-common                aarch64  8.0.45-1.el9_7           appstream   67 k
    ##### snipped #####
    Complete!

    Use

    $ sudo dnf module install mysql:8.4/server

    on RHEL 9.6 and later when you want the MySQL 8.4 stream, and use

    $ sudo dnf install --assumeyes mysql8.4-server

    on RHEL 10 or CentOS Stream 10. Current Fedora releases can offer both mysql-server and mysql8.4-server, so install the package name that matches the stream you intend to run.

  7. Enable and start the database service.
    $ sudo systemctl enable --now mysqld
    Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service -> /usr/lib/systemd/system/mysqld.service.

    Use

    $ sudo systemctl enable --now mariadb

    if MariaDB was installed.

  8. Verify that the selected database service is running.
    $ sudo systemctl status mysqld
    ● mysqld.service - MySQL Server
         Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: disabled)
         Active: active (running) since Thu 2026-04-09 15:38:11 UTC; 10s ago
         Status: "Server is operational"
    ##### snipped #####

    Check mariadb.service with

    $ sudo systemctl status mariadb

    when the host is running MariaDB instead.

  9. Run the post-install hardening script for the server you installed.
    $ sudo mysql_secure_installation
    
    Securing the MySQL server deployment.
    
    Enter password for user root:

    For MariaDB, run

    $ sudo mariadb-secure-installation

    . Current RHEL family MariaDB packages also ship mysql_secure_installation as a compatibility command, but the MariaDB command name is clearer in mixed environments.

  10. Set a password for the administrative root account when the script prompts for it.
    Estimated strength of the password: 100
    Change the password for root ? ((Press y|Y for Yes, any other key for No) : Y
    
    New password:
    
    Re-enter new password:
    
    Estimated strength of the password: 100
    Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y

    Avoid passing the password on the command line or storing it in shell history, scripts, or shared notes.

  11. Remove anonymous database accounts.
    Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
    Success.
  12. Disallow remote login for the root account.
    Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
    Success.

    Use a separate administrative user with only the required database privileges when remote administration is actually needed.

  13. Remove the default test database.
    Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
     - Dropping test database...
    Success.
    
     - Removing privileges on test database...
    Success.
  14. Reload the privilege tables so the hardening changes take effect immediately.
    Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
    Success.
  15. Connect locally with the client and confirm that the server answers queries.
    $ mysql -u root -p -A
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 22
    Server version: 8.0.45 Source distribution
    ##### snipped #####
    mysql> SELECT VERSION();
    +-----------+
    | VERSION() |
    +-----------+
    | 8.0.45    |
    +-----------+
    1 row in set (0.00 sec)
    
    mysql> exit
    Bye

    On MariaDB, the same test often reports a version string such as 10.11.16-MariaDB, and

    $ mariadb -u root -p -A

    works too if you prefer the native client command name.