Installation guides

Installing MariaDB on RHEL

Step-by-Step Guide

  1. Update the Package Index
    Open a terminal and update the package index to ensure you have the latest information about available packages:
   sudo yum update -y
  1. Add the MariaDB Repository
    Create a new MariaDB repository file:
   sudo nano /etc/yum.repos.d/MariaDB.repo

Add the following content to the file:

   [mariadb]
   name = MariaDB
   baseurl = http://yum.mariadb.org/10.5/rhel7-amd64
   gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
   gpgcheck=1
  1. Install MariaDB
    Install MariaDB using the yum package manager:
   sudo yum install MariaDB-server MariaDB-client -y
  1. Start and Enable MariaDB
    Start the MariaDB service:
   sudo systemctl start mariadb

Enable MariaDB to start on boot:

   sudo systemctl enable mariadb
  1. Secure MariaDB Installation
    Run the security script that comes pre-installed with MariaDB to improve the security of your installation:
   sudo mysql_secure_installation

This script will prompt you to set a root password, remove anonymous users, disallow root login remotely, remove test databases, and reload the privilege tables. Follow the prompts and answer accordingly.

  1. Verify MariaDB Installation
    Check the MariaDB service status to ensure it is running:
   sudo systemctl status mariadb

If MariaDB is running, you should see an active (running) status.

  1. Log In to MariaDB
    Log in to the MariaDB root administrative account:
   sudo mysql -u root -p

You will be prompted to enter the root password you set during the secure installation process.

  1. Create a New Database (Optional)
    To create a new database, use the following SQL command within the MariaDB prompt:
   CREATE DATABASE your_database_name;
  1. Create a New MariaDB User (Optional)
    To create a new MariaDB user and grant it permissions, use the following SQL commands:
   CREATE USER 'your_username'@'localhost' IDENTIFIED BY 'your_password';
   GRANT ALL PRIVILEGES ON your_database_name.* TO 'your_username'@'localhost';
   FLUSH PRIVILEGES;

This will create a new user and grant them all privileges on the specified database.

  1. Test MariaDB
    To verify that MariaDB is functioning correctly, exit the MariaDB prompt and try logging in as the new user: mysql -u your_username -p You will be prompted to enter the password for the new user. Once logged in, you can list the available databases to ensure your new database is present: SHOW DATABASES;
  2. Backup and Restore Databases (Optional)
    To back up a database, use the mysqldump command:
    bash mysqldump -u your_username -p your_database_name > your_database_name.sql
    To restore a database from a backup file, use the mysql command:
    bash mysql -u your_username -p your_database_name < your_database_name.sql
Other Recent Posts