This guide covers the process of installing MariaDB , configuring basic settings, securing the database server, and performing initial database operations. These steps are essential for preparing MariaDB for production use.
Install the MariaDB Server Package
dnf -y install mariadb-server
Configure Default Charset
/etc/my.cnf.d/charset.cnf to set the default character set to utf8mb4:[mysqld]
character-set-server = utf8mb4
[client]
default-character-set = utf8mb4
Enable and Start the MariaDB Service
systemctl enable --now mariadb
firewall-cmd --add-service=mysql --permanent
firewall-cmd --reload
mysql_secure_installation script to secure your MariaDB installation. This interactive script guides you through setting root passwords, removing test databases, and more:mysql_secure_installation
Connecting to MariaDB
mysql
Creating and Managing Databases and Tables
CREATE DATABASE test_database;
CREATE TABLE test_database.test_table (id INT, name VARCHAR(50), address VARCHAR(50), PRIMARY KEY (id));
INSERT INTO test_database.test_table(id, name, address) VALUES("001", "CentOS", "Hiroshima");
SELECT * FROM test_database.test_table;
DROP DATABASE test_database;
Exiting MariaDB
exit
systemctl stop mariadb
rm -rf /var/lib/mysql/*
mysql_install_db --datadir=/var/lib/mysql --user=mysql
systemctl start mariadb