MariaDB is a popular open-source relational database management system and a drop-in replacement for MySQL. This guide will walk you through installing and configuring MariaDB on AlmaLinux.
Prerequisites
Ensure you have root or sudo privileges. Before installation, update the package repository:
sudo dnf update -y
Installing MariaDB from Package Manager
Run the MariaDB repository setup script:
wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
chmod +x mariadb_repo_setup
sudo ./mariadb_repo_setup
Use the package manager to install MariaDB:
sudo dnf install mariadb-server -y
Start and Enable MariaDB
sudo systemctl start mariadb
sudo systemctl enable mariadb
Secure MariaDB Server Installation
sudo mysql_secure_installation
This script prompts you to set the root password, remove anonymous users, restrict root login to local, and more.
Accessing MariaDB
Log in to MariaDB with the root user:
sudo mariadb -u root -p
Creating a Database and User
Create a new database and user with appropriate privileges:
CREATE DATABASE krython_database;
CREATE USER 'krython_user'@'localhost' IDENTIFIED BY 'krython_password';
GRANT ALL PRIVILEGES ON krython_database.* TO 'krython_user'@'localhost';
FLUSH PRIVILEGES;
Replace krython_database
, krython_user
, and krython_password
with your desired values.
Adjusting MariaDB Configuration
Edit the MariaDB configuration file to optimize performance:
sudo nano /etc/my.cnf.d/server.cnf
Add or modify parameters such as innodb_buffer_pool_size
based on your system requirements.
Restarting MariaDB
After making changes, restart the MariaDB service:
sudo systemctl restart mariadb
Conclusion
Congratulations! You’ve successfully installed and configured MariaDB on AlmaLinux. Your database server is now ready for production use with proper security measures in place.