Menu

How to Install MariaDB on Oracle Linux 7 (Legacy Guide)

Legacy MariaDB guide for Oracle Linux 7; Extended Support began in January 2025 and requires an Oracle support entitlement.

Posted on By Updated on
On this page

This guide documents the default MariaDB package on Oracle Linux 7 for maintaining an existing system. Oracle Linux 7 moved from Premier Support to Extended Support on January 1, 2025; Extended Support requires an applicable Oracle Linux support contract. Do not use this legacy system as the starting point for a new production deployment. For a new MariaDB host, see MariaDB on Oracle Linux 9. See Oracle’s Oracle Linux 7 support notice and Extended Support policy.

Prerequisites

Before you begin, make sure you have:

  1. An Oracle Linux 7 system.
  2. Root or sudo access.
  3. An active internet connection.

Step 1: Update Your System

First, ensure your Oracle Linux 7 system is up to date with the latest software and security updates. Open a terminal and run the following commands:

sudo yum update

This command will update your system’s package repository.

Step 2: Install MariaDB

Oracle Linux 7 includes MariaDB in its default repositories, making installation simple. Use the following command to install MariaDB:

sudo yum install mariadb-server

During the installation, you’ll be prompted to confirm the package installation. Type ‘y’ and press Enter.

Step 3: Start and Enable MariaDB

After installation, start the MariaDB service and enable it to start at boot with the following commands:

sudo systemctl start mariadb
sudo systemctl enable mariadb

You can verify that MariaDB is running with this command:

sudo systemctl status mariadb

Step 4: Secure Your MariaDB Installation

MariaDB comes with a script that helps you secure your database installation. Run the following command:

sudo mysql_secure_installation

You’ll be prompted to set a root password, remove anonymous users, disallow root login remotely, and remove the test database. Follow the prompts and answer ‘Y’ or ‘N’ as needed.

Step 5: Log In to MariaDB

Now that your MariaDB installation is secure, you can log in to the database server using the following command:

mysql -u root -p

Enter the root password you set during the installation when prompted.

Step 6: Create a New Database and User

To create a new database and user, follow these steps:

  1. Log in to MariaDB as the root user.

  2. Create a new database (replace mydatabase with your preferred name):

    CREATE DATABASE mydatabase;
    
  3. Create a runtime application account with row-level privileges. Use a separate migration account for schema changes; replace myuser and the password placeholder with the intended account name and a unique secret from a password manager:

    CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'replace-with-a-unique-secret';
    GRANT SELECT, INSERT, UPDATE, DELETE ON mydatabase.* TO 'myuser'@'localhost';
    
  4. Exit the MariaDB prompt:

    exit;
    

Step 7: Test Your MariaDB Installation

You can test your new database and user by logging in with the created credentials:

mysql -u myuser -p

Enter the password when prompted, and you should now have access to the database you created.

Conclusion

This procedure can help maintain an existing Oracle Linux 7 server with applicable support coverage. For a new deployment, use a currently supported operating-system release; see the MariaDB on Oracle Linux 9 guide.