16 C
Texas
angeloma
Senior Writer and partner

Install MariaDB on Debian 11

Hello, friends. It is not yet known for sure which is the most used database driver, but MariaDB has to be in the first place. So, in this post, you will learn how to install MariaDB on Debian 11. This step is essential if you want to have applications running on your system.

MariaDB is a well-known archi Database Relationships Management System that is a MySQL fork. This is due to the purchase of Sun Mycrosystem by Oracle. It is perfectly compatible with MySQL and is available in most Linux distributions.

Therefore, it is quite popular and many developers use it for their applications or even to manage the most sensitive data you can imagine.

So, let’s go for it.

Install MariaDB on Debian 11

- Advertisement -

As it usually happens, MariaDB is available from the official Debian 11 repositories. If you want to check it out, then, just run the following command

apt search mariadb

There you will see many packages related to MariaDB such as the server and the client.

So, to install the server that concerns us today, then you can run the following command

apt install mariadb-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  galera-4 gawk libconfig-inifiles-perl libdbi-perl libmariadb3 libmpfr6 libsigsegv2 libsnappy1v5 mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common
  mariadb-server-10.5 mariadb-server-core-10.5 mysql-common socat
Suggested packages:
  gawk-doc libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl mailx mariadb-test netcat-openbsd
Recommended packages:
  libdbd-mariadb-perl | libdbd-mysql-perl libterm-readkey-perl libhtml-template-perl
The following NEW packages will be installed:
  galera-4 gawk libconfig-inifiles-perl libdbi-perl libmariadb3 libmpfr6 libsigsegv2 libsnappy1v5 mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common
  mariadb-server mariadb-server-10.5 mariadb-server-core-10.5 mysql-common socat
0 upgraded, 16 newly installed, 0 to remove and 0 not upgraded.
Need to get 18.0 MB of archives.
After this operation, 157 MB of additional disk space will be used.
Do you want to continue? [Y/n]

There is a package that refers to the MariaDB client which is mariadb-client that you can install at your convenience.

To check the version of MariaDB installed, you can run the following command

mariadb --version
mariadb Ver 15.1 Distrib 10.5.11-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper

As with other system services, when MariaDB is installed, it will be started and enabled so that it can start with the system.

You can stop the service by running

systemctl stop mariadb

If you want to start it again, then run

systemctl start mariadb

Finally, you can check the status of the service by running this command

systemctl status mariadb
● mariadb.service - MariaDB 10.5.11 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-08-17 23:38:11 CEST; 21min ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 9881 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 9882 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 9884 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl se>
   Process: 9946 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 9948 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 9932 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 9 (limit: 2277)
     Memory: 89.9M
        CPU: 1.187s
     CGroup: /system.slice/mariadb.service
             └─9932 /usr/sbin/mariadbd

Aug 17 23:38:11 osradar mariadbd[9932]: 2021-08-17 23:38:11 0 [Note] InnoDB: 10.5.11 started; log sequence number 45130; transaction id 20
Aug 17 23:38:11 osradar mariadbd[9932]: 2021-08-17 23:38:11 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Aug 17 23:38:11 osradar mariadbd[9932]: 2021-08-17 23:38:11 0 [Note] InnoDB: Buffer pool(s) load completed at 210817 23:38:11
Aug 17 23:38:11 osradar mariadbd[9932]: 2021-08-17 23:38:11 0 [Note] Plugin 'FEEDBACK' is disabled.
Aug 17 23:38:11 osradar mariadbd[9932]: 2021-08-17 23:38:11 0 [Note] Server socket created on IP: '127.0.0.1'.
Aug 17 23:38:11 osradar mariadbd[9932]: 2021-08-17 23:38:11 0 [Note] Reading of all Master_info entries succeeded
Aug 17 23:38:11 osradar mariadbd[9932]: 2021-08-17 23:38:11 0 [Note] Added new Master_info '' to hash table
Aug 17 23:38:11 osradar mariadbd[9932]: 2021-08-17 23:38:11 0 [Note] /usr/sbin/mariadbd: ready for connections.
Aug 17 23:38:11 osradar mariadbd[9932]: Version: '10.5.11-MariaDB-1'  socket: '/run/mysqld/mysqld.sock'  port: 3306  Debian 11
Aug 17 23:38:11 osradar systemd[1]: Started MariaDB 10.5.11 database server.

Preparing MariaDB for use

When MariaDB is installed, it does not include a password for the root user, so it is immediately necessary to set one. For this, we have the mysql_secure_installation script to help us with this.

mysql_secure_installation

When prompted for the root user password, just press ENTER:

Enter current password for root (enter for none):

Now you can define the MariaDB authentication protocol.

If You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n]

And now yes, you can change the root password by answering Y to the question

Change the root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables...
... Success!

Then, there follows a series of questions that have to do with MariaDB configuration and security. You can answer each one AND

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

And then the script will finish executing.

With this, MariaDB will be ready for you to use and access the shell.

mysql -u root -p

Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 54
Server version: 10.5.11-MariaDB-1 Debian 11
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)]>

So, enjoy it

Conclusion

MariaDB is a database driver widely used by many programming enthusiasts. Learning how to install it can pave the way to getting the most out of it in this area.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article