How to Install MariaDB on Debian 10
Choose a different version or distribution
Introduction
Before we begin discussing, how to install MariDB on Debian 10, let's briefly understand – What is MariaDB?
MariaDB is a powerful and popular open-source database management system. It is a fork of MySQL and offers enhanced features, performance, and security. MariaDB is widely used by businesses and developers for managing large amounts of data.
It supports multiple programming languages and platforms, making it versatile and easy to integrate into various applications. With its user-friendly interface and robust capabilities, MariaDB is an excellent choice for anyone seeking a reliable and efficient database solution.
In this tutorial, you will install MariaDB on Debian 10.
Advantages of MariaDB
- Enhanced Performance: MariaDB offers improved query optimization and faster data processing, resulting in quicker response times.
- High Security: It provides advanced security features such as encryption, authentication plugins, and firewall integration to protect data from unauthorized access.
- Scalability: MariaDB can handle large amounts of data and high traffic loads, making it suitable for growing businesses.
- Compatibility: It is a drop-in replacement for MySQL, ensuring seamless migration with existing applications and frameworks.
- Active Community: MariaDB has a vibrant community of developers, providing regular updates, bug fixes, and extensive documentation.
Install MariaDB on Debian 10
The most recent version of MariaDB that is accessible through the Debian repositories at the time of writing this tutorial is version 10.3.
To install MariaDB on Debian 10, perform the following steps as root or a user with sudo privileges:
1) Update the packages index first:
sudo apt update
2) Run the command below to install the MariaDB server and client packages:
sudo apt install mariadb-server
3) The MariaDB service will launch on its own. Check the service status to verify it:
sudo systemctl status mariadb
The output should resemble this:
Output
● mariadb.service - MariaDB 10.3.15 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-07-11 14:36:28 PDT; 19min ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 4509 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 30 (limit: 2359)
Memory: 78.6M
CGroup: /system.slice/mariadb.service
└─4509 /usr/sbin/mysqld
How to Secure MariaDB
A script that is included with MariaDB can help you increase installation security. Enter mysql_secure_installation
in your terminal to launch the script:
sudo mysql_secure_installation
You will be requested to change the root account's password, remove the anonymous user, deny root access to the local system, and delete the test database.
Output
...
Enter current password for root (enter for none):
...
Set root password? [Y/n] Y
New password:
Re-enter new password:
...
Remove anonymous users? [Y/n] Y
...
Disallow root login remotely? [Y/n] Y
...
Remove test database and access to it? [Y/n] Y
...
Reload privilege tables now? [Y/n] Y
...
Thanks for using MariaDB!
If selected, the script will reload the privilege tables to make sure the modifications are instantly effective.
Each step is thoroughly explained, and it is advised that you select “Y” (yes) in response to all questions.
Authentication Methods
When calling the mysql
client tool, the MariaDB root user employs the unix_socket
authentication plugin, which checks the effective User ID by default.
This means that in order to connect to the MariaDB server as root, you must either invoke the mysql
command as system root or add the sudo command prefix.
It is advised to keep the default authentication plugin and only enable the root user to authenticate using Unix sockets for greater security.
Log in to the MariaDB server if you want to switch the root authentication to the standard one:
sudo mysql
To change the authentication plugin, run the following commands:
ALTER USER 'root'@'localhost' IDENTIFIED VIA mysql_native_password;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_root_passwd';
By using the new password, you can now access the MariaDB server:
mysql -u root -p
You can log in as root from a third-party program such as phpMyAdmin by changing the authentication plugin.
FAQs to Install MariaDB on Debian 10
What is the default root password for MariaDB on Debian 10?
During the installation, you'll be prompted to set a root password for MariaDB. Use that password to log in as the root user.
How do I start and stop the MariaDB service on Debian 10?
Use the commands sudo systemctl start mariadb
to start the service and sudo systemctl stop mariadb
to stop it.
Where are the MariaDB configuration files located in Debian 10?
The main configuration file is located at /etc/mysql/mariadb.conf.d/50-server.cnf
in Debian 10.
How can I access the MariaDB command-line interface on Debian 10?
Use the command mysql -u username -p
and replace "username" with your MariaDB username. You will be prompted to enter the password.
How do I grant privileges to a user in MariaDB on Debian 10?
Use the command GRANT privileges ON database.* TO 'username'@'localhost' IDENTIFIED BY 'password';
to grant specific privileges to a user.
How can I uninstall MariaDB from Debian 10?
Run the command sudo apt-get remove --purge mariadb-server
to uninstall MariaDB completely from your Debian 10 system.
Conclusion
We hope this tutorial helped you understand how to install and secure MariaDB on a Debian 10 server.
If you have any further queries or doubts, please leave a comment below. We will be happy to respond to them.