It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In RegisterIt looks like you're new here. If you want to get involved, click one of these buttons!
MariaDB is an open-source and freely licensed relational database management system created as a fork of MySQL. Despite some differences in product functionality, MariaDB is fully compatible with MySQL and the SQL query language. MariaDB provides reliable data storage for a variety of applications, from websites to enterprise systems. It supports many operating systems and popular programming languages, making it a popular choice for developers.
In this guide, you will learn how to install MariaDB on Debian (10, 11, 12 versions).
First, update system by running the following command:
apt-get update -y
Run this command to install the required dependencies:
apt-get install curl software-properties-common dirmngr gnupg2 -y
Run these commands to download and add the GPG key:
curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
bash mariadb_repo_setup --os-type=debian --os-version=buster --mariadb-server-version=11.3
First, download the MariaDB repository installation package:
wget http://ftp.us.debian.org/debian/pool/main/r/readline5/libreadline5_5.2+dfsg-3+b13_amd64.deb
Then run this command to install it:
dpkg -i libreadline5_5.2+dfsg-3+b13_amd64.deb
After that, repeat system update:
apt-get update -y
To install MariaDB, run this command:
apt-get install mariadb-server mariadb-client -y
To start and then enable MariaDB, run these commands:
systemctl start mariadb
systemctl enable mariadb
To check if MariaDB is active, run the following command:
systemctl status mariadb
It will show you information about status of MariaDB on your server (including MariaDB version):
The default MariaDB installation is not secured, so we highly recommend you to set root password and adjust some security settings. First, run this command:
mysql_secure_installation
By default root password is empty so just press enter and continue. You will be asked if you want to change the root password, so enter "y" and enter the new password. All subsequent questions should be answered with the letter “y”.
Now you can access your root user with new password:
mariadb -u root -p
To create a new database, run this command (you can use any name instead of 'my_database'):
CREATE DATABASE my_database;
To create a new MariaDB user, run the following command (change the 'username' and 'password' to the actual credentials):
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
Then flush privileges and exit:
FLUSH PRIVILEGES;
EXIT;
Before creating a table, select the database in which you want to do it:
USE my_database;
You can then create a table and specify what data you want to store in it (this is just an example):
CREATE TABLE employees (id INT, name VARCHAR(20), surname VARCHAR(20));
You can check your table by running this command:
SHOW TABLES;
You should see such output:
To insert some data, run this command:
INSERT INTO employees (id,name,surname) VALUES(01,"John","Smith");
To check inserted data run this command:
SELECT * FROM employees;
You should see this output: