MariaDB is an excellent free, open-source relational database management system. The software is a backward-compatible replacement for MySQL as it was created and is actively developed by the original developers of MySQL. MariaDB is a fast, robust database system filled with extras like additional storage engines, plugins and many other features.
MariaDB is the default implementation of MySQL in Debian 10 Buster. The tutorial below will explain how to install MariaDB and basic configuration.
You will need an account with sudo privileges or root access. Then check that your system is up to date.
sudo apt update && sudo apt upgrade -y
Install MariaDB server package and client from Debian’s default repository with the following command.
sudo apt install mariadb-server
The following packages will also be installed on your system.
Check MariaDB status
Once installed, you should check to see MariaDB’s status. By default, it should start automatically.
sudo systemctl status mariadb
If the service has not started, run the following commands. Additional commands are listed as well.
sudo systemctl start mariadb
Enable MariaDB on start-up
sudo systemctl enable mariadb
sudo systemctl restart mariadb
sudo systemctl reload mariadb
sudo systemctl stop mariadb
The recommendation that after you install MariaDB, you should secure it. You can do this quickly in a few steps.
First, run the following command.
Next, you need to follow the following prompt to set a root password, remove anonymous users, disallow root login remotely, remove the test database and finish by reloading the privilege table to secure your MariaDB server database.
Enter current password for root (enter for none): #### Press enter key ####
Set root password? [Y/n] #### Type "Y" ####
Re-enter new password:
Remove anonymous users? [Y/n] #### Type "Y" ####
Disallow root login remotely? [Y/n] #### Type "Y" ####
Remove test database and access to it? [Y/n] #### Type "Y" ####
Reload privilege tables now? [Y/n] #### Type "Y" ####
Thanks for using MariaDB!
Now that you have finished installing and securing the software, you can now open it by typing.
mysql -u root -p
Running MariaDB, you use the root command due to the protocol in place using the unix_socket authentication plugin, verifying the user identification level when calling the MariaDB/MySQL client. The recommended security protocol is that you run MariaDB as root. Invoking classic commands is not recommended.
Next, test out the client by creating a database. We do this with the following commands.
The commands used above as follows.
- Create database:
CREATE DATABASE test_database;
2. Access Privilages Grant:
GRANT ALL ON test_database.* TO 'test-user'@'localhost' IDENTIFIED BY 'bytesboss_user_password' WITH GRANT OPTION;
3. Flush privileges for the changes to become active:
4. Exit MariaDB terminal:
Test Created User & Database
Now, you can check out what you just created by logging into the created user. Then list the databases created.
Log in as the created user you made with the set password:
mysql -u test_user -p
Show the databases attached to the user:
MariaDB [(none)]> SHOW DATABASES;
Congratulations, you have successfully install MariaDB for Debian 10, secure the software and created a database and username with a set password.
Comments and Conclusion
MariaDB is a solid piece of hardware. It’s fast and secure and is the essential database used in “LEMP” with NGINX and PHP full-stack. Some benefits of using MariaDB over traditional MySQL are to visit the MariaDB vs MySQL blog post created by the software developers. It outlines the case and its advantages.