In this guide we are going to install MariaDB 10 on Opensuse, but first what is MariaDB?
MariaDB Server is one of the most popular open-source relational databases. It’s made by the original developers of MySQL and guaranteed to stay open source. It is part of most cloud offerings and the default in most Linux distributions.
It is built upon the values of performance, stability, and openness, and MariaDB Foundation ensures contributions will be accepted on technical merit. Recent new functionality includes advanced clustering with Galera Cluster 4, compatibility features with Oracle Database and Temporal Data Tables, allowing one to query the data as it stood at any point in the past.
Install MariaDB on OpenSuse 15.4
1. Update system repositories
To begin the installation, lets first update the repositories in order to make them up to date.
$ sudo zypper ref
$ sudo zypper update -y
2. Install MariaDB 10 on OpenSuse 15.4
To install MariaDB, we are going to configure zypper
so that we can use to make the installation. Use the following command to add MariaDB to zypper.
sudo zypper addrepo --gpgcheck --refresh https://yum.mariadb.org/10.6/sles/15/x86_64 mariadb
Import Keys to sign the MariaDB on OpenSuse repositories.
sudo rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
sudo zypper --gpg-auto-import-keys refresh
To install MariaDB use the following command.
sudo zypper install MariaDB-server
To install commonly used packages use the following command.
sudo zypper install galera MariaDB-shared MariaDB-backup MariaDB-common
3. Initial MariaDB configuration
The installation process will not ask you to set a password and this leaves MariaDB insecure. We will use a script that the MariaDB-server package provides strict access to the server and remove unused accounts. Read more about the security script here.
To ensure that our database is secure we need to run the mysql_secure_installation command to remove all remote root login, remove anonymous users, etc.
$ sudo mysql_secure_installation
Following the prompts to secure your MariaDB
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set 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!
Next is to enable MariaDB database
$ sudo systemctl enable mariadb
Start MariaDB database
$ sudo systemctl start mariadb
Check the status of the MariaDB database
$ sudo systemctl status mariadb
You will see the following as the output.
● mariadb.service - MariaDB 10.3.35 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor p>
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Wed 2022-07-06 13:58:41 UTC; 8s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 7810 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_ST>
Process: 7813 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && >
Process: 7936 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_S>
Main PID: 7836 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 30 (limit: 1129)
CGroup: /system.slice/mariadb.service
└─7836 /usr/sbin/mysqld
Jul 06 13:58:41 localhost mysqld[7836]: 2022-07-06 13:58:41 0 [Note] InnoDB: 10>
Jul 06 13:58:41 localhost mysqld[7836]: 2022-07-06 13:58:41 0 [Note] InnoDB: Lo>
Jul 06 13:58:41 localhost mysqld[7836]: 2022-07-06 13:58:41 0 [Note] Plugin 'FE>
Jul 06 13:58:41 localhost mysqld[7836]: 2022-07-06 13:58:41 0 [Note] InnoDB: Bu>
Jul 06 13:58:41 localhost mysqld[7836]: 2022-07-06 13:58:41 0 [Note] Server soc>
Jul 06 13:58:41 localhost mysqld[7836]: 2022-07-06 13:58:41 0 [Note] Reading of>
lines 1-22
To test MariaDB we can create a database. Login to MariaDB console with the following command.
$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.3.35-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SELECT VERSION();
+-----------------+
| VERSION() |
+-----------------+
| 10.3.35-MariaDB |
+-----------------+
1 row in set (0.000 sec)
MariaDB [(none)]>
Conclusion
We have learned how to install MariaDB on Ubuntu 21.04 server and secured it using the mysql_secure_installation
script. You can now practice running SQL queries to learn more. I hope you enjoyed it and you have learned something new.