Table of Contents
MariaDB server 5.5
MariaDB Server is available and supported on RHEL 7 and CentOS 7 and is easily deployed from OS vendor repositories or MariaDB repositories using yum.
The RHEL 7 and CentOS 7 distributions include MariaDB Server 5.5 by default. You can install MariaDB Server using this command: sudo yum install mariadb-server
# mysql -u root Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 5.5.68-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Add MariaDB YUM repository
1. To deploy MariaDB Server 10.x and later on RHEL 7 or CentOS 7, first download and use the mariadb_repo_setup script to configure the MariaDB repositories for yum:
sudo yum -y update
curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup sudo bash mariadb_repo_setup --mariadb-server-version=10.8
List all available repositories on the system
sudo yum clean all sudo yum repolist | grep mariadb
# sudo yum clean all # sudo yum repolist | grep mariadb mariadb-main MariaDB Server 131 mariadb-maxscale MariaDB MaxScale 4 mariadb-tools MariaDB Tools 16
Install MariaDB 10.x on CentOS 7
MariaDB 10.x packages are available on the repo we just added. Let’s install server and client packages.
sudo yum install MariaDB-server MariaDB-client MariaDB-backup -y
rpm -qi MariaDB-server
[root@centos7 tmp]# rpm -qi MariaDB-server Name : MariaDB-server Version : 10.8.5 Release : 1.el7.centos Architecture: x86_64 Install Date: Tue 25 Oct 2022 08:29:54 AM UTC Group : Applications/Databases Size : 129526813 License : GPLv2 Signature : DSA/SHA1, Fri 16 Sep 2022 05:21:14 AM UTC, Key ID cbcb082a1bb943db Source RPM : MariaDB-server-10.9.3-1.el7.centos.src.rpm Build Date : Tue 13 Sep 2022 09:21:04 PM UTC Build Host : centos74-amd64 Relocations : (not relocatable) Vendor : MariaDB Foundation URL : http://mariadb.org
Configure MariaDB 10.x on CentOS 7
1. Start and enable the mariadb database service on boot.
systemctl enable mariadb && systemctl start mariadb && systemctl status mariadb
# systemctl enable mariadb && systemctl start mariadb && systemctl status mariadb Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service. ● mariadb.service - MariaDB 10.8.5 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/mariadb.service.d └─migrated-from-my.cnf-settings.conf Active: active (running) since Tue 2022-10-25 06:15:20 EDT; 7ms ago Docs: man:mariadbd(8) https://mariadb.com/kb/en/library/systemd/
# mariadb -V mariadb Ver 15.1 Distrib 10.8.5-MariaDB, for Linux (x86_64) using readline 5.1
3. Use the mariadb-secure-installation script to secure your MariaDB database server
# sudo mariadb-secure-installation You already have your root account protected, so you can safely answer 'n'. Change the root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
4. Access to MariaDB shell using the password that you’ve created in the previous step.
# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 13 Server version: 10.8.5-MariaDB MariaDB Server MariaDB [(none)]> SELECT VERSION (); +----------------+ | VERSION () | +----------------+ | 10.8.5-MariaDB | +----------------+ 1 row in set (0.000 sec)
5. Create a test database/user in MariaDB in Centos 7.
MariaDB [(none)]> CREATE DATABASE mydb; Query OK, 1 row affected (0.001 sec) MariaDB [(none)]> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mydb | | mysql | | performance_schema | | sys | +--------------------+ 5 rows in set (0.001 sec)