As you already learned about MariaDB in recent articles, We are going to present the tutorial MariaDB installation on Debian 10. To introduce MariaDB, the one of the most popular open-source database management system, we can say it is a common alternative used for the MySQL portion of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. And part of most cloud offerings and the default in most Linux distributions. You should receive the compatible MariaDB replacement versions instead, If you attempt to install MySQL server related packages.
We will review the following steps until the installation guide finish.
- Update your package index using apt
- Install the mariadb-server package using apt. The package also pulls in related tools to interact with MariaDB
- Run the included mysql_secure_installation security script to restrict access to the server
The tutorial may be more useful if you know:
- a non-root user with sudo privileges
- To set up, follow our Initial Setup with Debian 10
Tutorial MariaDB installation on Debian 10
1- Installing MariaDB
Update the package index on your server with apt to install it
sudo apt update
To install the package:
sudo apt install mariadb-server
2- Configuring MariaDB
Run the security script:
After this, you may face a series of prompts to make some changes to your MariaDB installation’s security options. When you are prompted to enter the current database root password therefore press ENTER to indicate “none”.
The next prompt is about to set up a database root password. Type N and then press ENTER. In Debian, the root account for MariaDB is tied closely to automated system maintenance.
To accept the defaults for all the subsequent questions, you can press Y and then ENTER, to remove some anonymous users and the test database, disable remote root logins.
3- Adjusting User Authentication and Privileges
You should create a new account named admin with the same capabilities as the root account, but configured for password authentication. In other words, open up the MariaDB prompt from your terminal run the following.
To create a new user with root privileges and password-based access, change the username and password to match your preferences.
MariaDB [(none)]> GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
You can flush the privileges to ensure that they are saved and available in the current session.
MariaDB [(none)]> FLUSH PRIVILEGES;
Now you can exit the MariaDB shell:
MariaDB [(none)]> exit
4- Testing MariaDB
After installation after default repositories, MariaDB should start running automatically. Use the command below to test it.
sudo systemctl status mariadb
The output will display as below.
mariadb.service - MariaDB 10.3.15 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2019-07-12 20:35:29 UTC; 47min ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Main PID: 2036 (mysqld) Status: "Taking your SQL requests now..." Tasks: 30 (limit: 2378) Memory: 76.1M CGroup: /system.slice/mariadb.service └─2036 /usr/sbin/mysqld Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start: Phase 6/7: Checking and upgrading tables Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start: Running 'mysqlcheck' with connection arguments: --socket='/var/run/mysqld/mysqld.sock' --host='localhost' --socket='/var/run/mysqld/mysqld.sock' --host='localhost' --socket='/var/run/mysqld/mysqld.sock' Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start: # Connecting to localhost... Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start: # Disconnecting from localhost... Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start: Processing databases Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start: information_schema Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start: performance_schema Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start: Phase 7/7: Running 'FLUSH PRIVILEGES' Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start: OK Jul 12 20:35:30 deb-mariadb1 /etc/mysql/debian-start: Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables
You can start the MariaDB after running with the sudo systemctl start mariadb command, but to check more, try connecting to the database using the mysqladmin tool. In addition, for example, the below command means to connect to MariaDB as root. And return the version using the Unix socket:
sudo mysqladmin version
An output similar to below should be displayed.
mysqladmin Ver 9.1 Distrib 10.3.15-MariaDB, for debian-linux-gnu on x86_64 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Server version 10.3.15-MariaDB-1 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 48 min 14 sec Threads: 7 Questions: 474 Slow queries: 0 Opens: 177 Flush tables: 1 Open tables: 31 Queries per second avg: 0.163
In case of configuration a separate administrative user with password authentication. After that, perform the same operation by running the below command.
mysqladmin -u admin -p version
In conclusion, MariaDB is up and running and that your user is able to authenticate successfully now.
Dear user, we hope you would enjoy this tutorial, you can ask questions about this training in the comments section, or to solve other problems in the field of Eldernode training, refer to the Ask page section and raise your problems in it.
Suggested to read