MariaDB is a widely-used database management system known for its reliability, performance, and robust features. In this comprehensive guide, we will walk you through the step-by-step process of installing MariaDB on AlmaLinux 8. By the end of this tutorial, you will have a fully functional MariaDB server up and running on your AlmaLinux system.
Prerequisites
Before we begin, make sure you have the following prerequisites in place:
- AlmaLinux 8 installed on your system.
- Access to the root account or a user account with sudo privileges.
Step 1: Creating the MariaDB Repository File
To start the installation process, we first need to create a MariaDB repository configuration file. This file will allow AlmaLinux to fetch the necessary packages for the installation. Follow the steps below to create the repository file:
- Open a terminal or SSH into your AlmaLinux system.
- Use the following command to create the repository file:
sudo vi /etc/yum.repos.d/mariadb.repo
- In the newly created file, paste the following configuration:
[mariadb]
name = MariaDB
baseurl = https://mirror.23m.com/mariadb/yum/10.11/rhel/$releasever/$basearch
module_hotfixes = 1
gpgkey = https://mirror.23m.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1
- Save the file and exit the text editor.
Step 2: Installing MariaDB Server
Now that we have set up the repository, we can proceed with the installation of the MariaDB server. Follow the steps below to install MariaDB:
- Open a terminal or SSH into your AlmaLinux system.
- Run the following command to install the MariaDB server and client packages:
sudo dnf install MariaDB-server MariaDB-client
- During the installation process, you will be prompted to confirm the download and installation of the packages. Type
y
and press Enter to proceed.
Once the installation is complete, you will have the MariaDB server installed on your AlmaLinux system.
Step 3: Verifying the Installation
To ensure that the installation was successful, you can verify the version of the MariaDB server by using the following command:
mysql -V
The output should display the version information, confirming that the MariaDB server is installed and accessible.
Step 4: Starting MariaDB Server
To start using the MariaDB server, you need to start the service. Follow the steps below to start the MariaDB server:
- Open a terminal or SSH into your AlmaLinux system.
- Use the following command to enable the MariaDB service to start automatically upon system boot:
sudo systemctl enable mariadb
- Start the MariaDB service by running the following command:
sudo systemctl start mariadb
- To verify the status of the MariaDB service, use the following command:
sudo systemctl status mariadb
The output of the status command should indicate that the MariaDB service is active and running.
Securing the MariaDB Server
To ensure the security of your MariaDB installation, it is recommended to secure the server by following these steps:
- Open a terminal or SSH into your AlmaLinux system.
- Start the MariaDB shell by running the following command:
sudo mysql
- Once you are in the MariaDB shell, execute the following commands to secure the server:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_new_password';
DELETE FROM mysql.user WHERE User='';
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
DROP DATABASE IF EXISTS test;
FLUSH PRIVILEGES;
EXIT;
Make sure to replace 'your_new_password'
with a strong password of your choice.
Creating a New Database and User
Now that your MariaDB server is secured, you can proceed with creating a new database and user. Follow the steps below to create a new database and user:
- Open a terminal or SSH into your AlmaLinux system.
- Log in to the MariaDB server as the root user by running the following command:
sudo mysql -u root -p
- Enter the password for the root user when prompted.
- In the MariaDB shell, execute the following commands to create a new database and user:
CREATE DATABASE example;
CREATE USER ccuser1;
GRANT ALL ON example.* TO ccuser1@localhost IDENTIFIED BY 'secretePasswordHere';
Replace 'secretePasswordHere'
with a strong password for the new user.
Accessing the Database
To access the MariaDB server with the newly created database and user, follow the steps below:
- Open a terminal or SSH into your AlmaLinux system.
- Log in to the MariaDB server with the new user by running the following command:
sudo mysql -u ccuser1 -p'secretePasswordHere' example
Replace 'secretePasswordHere'
with the password you set for the new user.
- Once logged in, you can verify the existence of the database by executing the following command:
show databases;
Congratulations! You have successfully installed, secured, and accessed MariaDB on your AlmaLinux 8 system.
Conclusion
In this comprehensive guide, we have walked you through the step-by-step process of installing MariaDB on AlmaLinux 8. We covered everything from creating the repository file to securing the server and creating a new database and user. By following these instructions, you now have a fully functional MariaDB installation ready to power your applications and websites.
If you are looking for reliable and high-performance cloud hosting solutions, consider Shape.host. They offer Linux SSD VPS services with cutting-edge technology and exceptional customer support.
So why wait? Start harnessing the power of MariaDB on AlmaLinux 8 today and take your applications to new heights with Shape.host’s cloud hosting services.