main logo

How to Install MySQL on Fedora 42

How to Install MySQL on Fedora 42

Fedora 42, representing the forefront of open-source innovation, offers a dynamic platform for developers and system administrators who require the latest software versions, including MySQL. This tutorial provides a comprehensive guide to installing MySQL Community Server on a Fedora 42 system. We will cover essential steps such as system updates, MySQL package installation (ideally via the official MySQL Yum repository or Fedora’s own repositories if sufficiently current), critical security hardening procedures, and effective MySQL service management. For users who need advanced server administration, performance optimization, or specialized Linux Server Support, professional services can provide significant advantages.

MySQL is a globally adopted, leading open-source relational database management system (RDBMS), indispensable for a vast spectrum of applications that rely on robust, scalable, and reliable data storage. This guide is designed to help you establish a secure, functional, and correctly configured MySQL installation on your Fedora 42 server.

Important Note on Fedora’s Release and Support Cycle: Fedora Linux is known for its rapid release schedule, with new versions appearing approximately every six months. Each release typically receives support for about 13 months. Users deploying Fedora 42 for production environments should be acutely aware of its End-Of-Life (EOL) date and proactively plan for timely system upgrades to maintain security and support.

Prerequisites

  • A server running Fedora 42.
  • A non-root user account that has been configured with sudo privileges.
  • Access to a terminal or command-line interface (CLI).

Before commencing with the installation, it is crucial to ensure that your Fedora 42 system is fully updated and that you have a sudo-enabled user. If needed, consult Fedora’s official initial server setup documentation for guidance on these preliminary configurations.

Step 1 — Updating System Packages

Prior to installing any new software on a Fedora system, particularly one that incorporates the latest software versions, it is imperative to ensure that all your system’s packages are current. This action refreshes the package metadata from configured repositories and applies the latest updates, bug fixes, and security patches to your installed software.

sudo dnf upgrade --refresh

Step 2 — Installing MySQL

Fedora’s official repositories often include reasonably recent versions of MySQL. However, for accessing the absolute latest releases, specific MySQL series, or ensuring you are getting packages directly from Oracle, using the official MySQL Yum repository is generally the recommended approach.

Method 1: Using Fedora’s Default Repositories (Verify Version Suitability)

First, you can check the availability and version of MySQL packages (e.g., community-mysql-server or mysql-community-server) within Fedora’s standard repositories:

sudo dnf search mysql-server

If a version suitable for your requirements is listed, you can proceed to install it directly using dnf:

sudo dnf install community-mysql-server # Or use the specific package name identified from the search

Method 2: Using the Official MySQL Yum Repository (Recommended for Latest or Specific Versions)

  1. Download the MySQL Yum Repository Setup RPM:
    Navigate to the MySQL Yum Repository download page on the official MySQL website. Download the correct RPM package specifically built for Fedora 42 (e.g., mysql80-community-release-fc42-...noarch.rpm or a newer equivalent for a MySQL 8.x LTS version like 8.4.x, if it has been made available for Fedora 42).

    “`bash

    Example for MySQL 8.0 – replace with the correct, current URL/filename for Fedora 42

    wget https://dev.mysql.com/get/mysql80-community-release-fc42-1.noarch.rpm
    “`
    (Disclaimer: The exact filename and URL will change as new versions are released. Always obtain the latest appropriate package directly from the official MySQL website.)

  2. Install the Downloaded Repository RPM:
    bash
    sudo dnf install mysql80-community-release-fc42-1.noarch.rpm # Adjust the filename to match your downloaded file

    This command adds the official MySQL Yum repository to your system’s DNF configuration and imports the necessary GPG key for verifying package signatures.

  3. Install MySQL Server Packages:
    With the MySQL repository configured, you can now install the MySQL server package:
    bash
    sudo dnf install mysql-community-server

After completing the installation using your chosen method, you must start the MySQL service:

sudo systemctl start mysqld

Verify that the service has started successfully and is currently running:

sudo systemctl status mysqld

The output should clearly indicate that the service is active (running).

If MySQL was installed from the official MySQL repository, it typically generates a temporary password for the root user during the initial setup process. This temporary password is logged in the MySQL error log file. You can retrieve it using a command like grep:

sudo grep 'temporary password' /var/log/mysqld.log

Securely note this temporary password, as it will be required in the subsequent security hardening step. If, however, MySQL was installed from Fedora’s native repositories, the initial root authentication mechanism might differ (e.g., it might default to using socket authentication, similar to Debian/Ubuntu systems, and may not set a temporary password).

Step 3 — Securing MySQL

MySQL provides an essential security script named mysql_secure_installation. It is imperative to run this script immediately after installation to harden your MySQL server against common vulnerabilities. This script will interactively guide you through several critical security configurations, including setting a new root password, removing anonymous user accounts, disallowing remote root logins, and removing the default test database.

Execute the script with sudo privileges:

sudo mysql_secure_installation
  1. Enter Temporary/Current Password: If a temporary password was generated during installation, you will be prompted to enter it. If not (e.g., if socket authentication is the default for root and no password was initially set), the script’s behavior might vary; it might directly ask if you wish to set a root password.
  2. VALIDATE PASSWORD Component: You will be asked if you want to enable the VALIDATE PASSWORD component. Enabling this is highly recommended for all production environments as it enforces strong password policies, thereby significantly enhancing the security of your database. If you select Yes (Y), you will then be prompted to choose a password validation policy level (0 for LOW, 1 for MEDIUM, or 2 for STRONG).
  3. Set New Root Password: You will be prompted to create and confirm a new password for the MySQL root user. Ensure you select a robust, unique password that adheres to any policies set by the VALIDATE PASSWORD component.
  4. Security-Related Questions: The script will then pose a series of yes/no questions designed to further secure your MySQL installation:
    • Remove anonymous users? (Strongly Recommended: Yes)
    • Disallow root login remotely? (Strongly Recommended: Yes)
    • Remove test database and access to it? (Strongly Recommended: Yes)
    • Reload privilege tables now? (Strongly Recommended: Yes)

Successfully completing all these steps is fundamental for establishing a secure MySQL deployment. For organizations with advanced security requirements or those needing ongoing, expert database administration, consider leveraging professional MySQL support.

Step 4 — Testing MySQL

After securing your MySQL installation, it is crucial to verify that you can successfully log in using the new root password and that the server is operational.

mysql -u root -p

Enter the new root password that you configured during the mysql_secure_installation process. A successful login will present you with the MySQL monitor prompt (mysql>).

Execute a simple command to confirm functionality, such as checking the MySQL server version:

SELECT VERSION();

To exit the MySQL monitor, type:

EXIT;

Step 5 — Managing the MySQL Service

The MySQL service on Fedora 42 is managed using the systemctl command-line utility, which is standard for systemd-based Linux distributions.

  • Start MySQL Service:
    bash
    sudo systemctl start mysqld
  • Stop MySQL Service:
    bash
    sudo systemctl stop mysqld
  • Restart MySQL Service: (Useful for applying certain configuration changes that require a service restart)
    bash
    sudo systemctl restart mysqld
  • Check MySQL Service Status: (Provides detailed information about the service’s current operational state)
    bash
    sudo systemctl status mysqld
  • Enable MySQL Service on Boot: (Ensures MySQL starts automatically when the server boots; this is typically configured by default during the installation process)
    bash
    sudo systemctl enable mysqld
  • Disable MySQL Service on Boot: (Prevents MySQL from starting automatically at system boot)
    bash
    sudo systemctl disable mysqld

Conclusion

You have now successfully installed and secured MySQL on your Fedora 42 server. Your database is prepared and ready for use with your applications. Given Fedora’s rapid release and relatively short support cycle, it is vital to stay informed about system updates and plan for timely upgrades to maintain a secure, supported, and functional environment, especially for production workloads.

For further information, advanced configurations, and related guides, these resources may prove helpful:

Robust and proactive database management is crucial for ensuring application stability, data integrity, and comprehensive security. If your organization requires expert assistance with database administration, performance optimization, or is considering comprehensive Managed IT Services, Medha Cloud offers a suite of tailored solutions designed to meet your specific infrastructure needs. Furthermore, for Managed Service Providers (MSPs) looking to enhance their service offerings, Medha Cloud provides white-label managed IT services, enabling you to expand your portfolio under your own distinct brand.

Medha Cloud
Medha Cloud
Medha Cloud, a leading multi-cloud service provider, focuses on cloud computing and digital transformation. Every article published under the Medha Cloud brand is a collaborative effort by our team. We are committed to sharing insights, best practices, how-tos, reviews, and real-world examples to help organizations stay ahead of the curve and thrive in the digital age
Share
Contents

Related Articles

medhacloud logo
USA:
Medha Cloud Solutions LLC
30 N Gould St Ste R, Sheridan, WY 82801,
Phone: +1 646 775 2855

India:
Medha Cloud Solutions Private Limited
#74, 7th Cross, Krishna Garden InCity Layout. Chikka Kammanahalli, Banneraghatta Road, Bangalore 560083
Phone:+91 93536 44646

E-Mail: sales@medhahosting.com
©Medha Cloud 2024. All rights reserved.