{"id":10147,"date":"2021-08-21T09:38:31","date_gmt":"2021-08-21T06:38:31","guid":{"rendered":"https:\/\/kifarunix.com\/?p=10147"},"modified":"2024-03-18T18:48:10","modified_gmt":"2024-03-18T15:48:10","slug":"install-mariadb-10-6-on-debian-11","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-mariadb-10-6-on-debian-11\/","title":{"rendered":"Install MariaDB 10.6 on Debian 11"},"content":{"rendered":"\n<p>Follow through this guide to learn how to install MariaDB 10.6 on Debian 11. \u201c<em><a href=\"https:\/\/mariadb.com\/kb\/en\/what-is-mariadb-106\/\" target=\"_blank\" rel=\"noreferrer noopener\">MariaDB 10.6<\/a>&nbsp;is the current&nbsp;stable&nbsp;series of MariaDB. It is an evolution of&nbsp;<a href=\"https:\/\/mariadb.com\/kb\/en\/what-is-mariadb-105\/\" target=\"_blank\" rel=\"noreferrer noopener\">MariaDB 10.5<\/a>&nbsp;with several entirely&nbsp;<a href=\"https:\/\/mariadb.com\/kb\/en\/changes-improvements-in-mariadb-106\/\" target=\"_blank\" rel=\"noreferrer noopener\">new features and improvements<\/a>&#8220;<\/em>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing MariaDB 10.6 on Debian 11<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Run System Update<\/h3>\n\n\n\n<p>Assuming that you are installing MariaDB 10.6 on a newly installed Debian 11, update and upgrade your system packages.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt update <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt upgrade<\/code><\/pre>\n\n\n\n<p>There are two methods in which you can install MariaDB;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#install-from-apt-repos\">Install MariaDB 10.6 from MariaDB APT repository<\/a><\/li>\n\n\n\n<li><a href=\"#install-using-deb-binary\">Install MariaDB 10.6 using MariaDB .DEB Binary file<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-from-apt-repos\">Install MariaDB 10.6 from APT Repository<\/h3>\n\n\n\n<p>MariaDB 10.5 is the currently available version on the default Debian 11 repos;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt show mariadb-server<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nPackage: mariadb-server\nVersion: 1:10.5.11-1\nPriority: optional\nSection: database\nSource: mariadb-10.5\nMaintainer: Debian MySQL Maintainers <pkg-mysql-maint@lists.alioth.debian.org>\nInstalled-Size: 72.7 kB\nDepends: mariadb-server-10.5 (>= 1:10.5.11-1)\nHomepage: https:\/\/mariadb.org\/\nTag: devel::lang:c++, devel::lang:sql, devel::library, implemented-in::c++,\n interface::commandline, interface::daemon, network::server,\n protocol::db:mysql, role::devel-lib, role::metapackage, role::program,\n works-with::db\nDownload-Size: 34.8 kB\nAPT-Sources: http:\/\/deb.debian.org\/debian bullseye\/main amd64 Packages\n<\/code><\/pre>\n\n\n\n<p>Therefore, to install MariaDB 10.6, you need to install MariaDB 10.6 APT repos.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Install MariaDB 10.6 APT repos on Debian 11<\/h4>\n\n\n\n<p>Execute the commands below to install MariaDB 10.6 APT repos;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install software-properties-common dirmngr<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt-key adv --fetch-keys 'https:\/\/mariadb.org\/mariadb_release_signing_key.asc'<\/code><\/pre>\n\n\n\n<p>Next, head over to <a href=\"https:\/\/downloads.mariadb.org\/mariadb\/repositories\" target=\"_blank\" rel=\"noreferrer noopener\">MariaDB repositories site<\/a> to choose your mirrors.<\/p>\n\n\n\n<p>Choose your Linux distro, distro release, MariaDB version to install and finally the Mirrors to use.<\/p>\n\n\n\n<p>To use UKfast mirrors, for example, run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add-apt-repository 'deb &#91;arch=amd64,arm64,ppc64el] https:\/\/mirrors.ukfast.co.uk\/sites\/mariadb\/repo\/10.6\/debian bullseye main'<\/code><\/pre>\n\n\n\n<p>Resynchronize your package cache;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt update<\/code><\/pre>\n\n\n\n<p>Install MariaDB 10.6;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install mariadb-server<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-using-deb-binary\">Install MariaDB 10.6 using .DEB Binary Files<\/h4>\n\n\n\n<p>While this is not the recommended way of installing MariaDB, you can as well download .deb binary files and install it.<\/p>\n\n\n\n<p>Follow the link below to learn how to install MariaDB using the .deb files.<\/p>\n\n\n\n<p><a href=\"https:\/\/mariadb.com\/kb\/en\/installing-mariadb-deb-files\/#installing-mariadb-with-dpkg\" target=\"_blank\" rel=\"noreferrer noopener\">Install MariaDB using deb binary files<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Verify the MariaDB installed version<\/h4>\n\n\n\n<p>To check the version of installed MariaDB, run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql -V<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql  Ver 15.1 Distrib 10.6.4-MariaDB, for debian-linux-gnu (x86_64) using readline EditLine wrapper<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Running MariaDB 10.6 on Debian 11<\/h4>\n\n\n\n<p>Upon installation, MariaDB is started and enabled to run on system boot;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl status mariadb<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n\u25cf mariadb.service - MariaDB 10.6.4 database server\n     Loaded: loaded (\/lib\/systemd\/system\/mariadb.service; enabled; vendor preset: enabled)\n    Drop-In: \/etc\/systemd\/system\/mariadb.service.d\n             \u2514\u2500migrated-from-my.cnf-settings.conf\n     Active: active (running) since Sat 2021-08-21 08:44:32 EAT; 5min ago\n       Docs: man:mariadbd(8)\n             https:\/\/mariadb.com\/kb\/en\/library\/systemd\/\n    Process: 3466 ExecStartPre=\/usr\/bin\/install -m 755 -o mysql -g root -d \/var\/run\/mysqld (code=exited, status=0\/SUCCESS)\n    Process: 3467 ExecStartPre=\/bin\/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0\/SUCCESS)\n    Process: 3469 ExecStartPre=\/bin\/sh -c [ ! -e \/usr\/bin\/galera_recovery ] && VAR= ||   VAR=`cd \/usr\/bin\/..; \/usr\/bin\/galera_recovery`; [ $? -eq 0 ]   && systemctl set-en>\n    Process: 3529 ExecStartPost=\/bin\/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0\/SUCCESS)\n    Process: 3531 ExecStartPost=\/etc\/mysql\/debian-start (code=exited, status=0\/SUCCESS)\n   Main PID: 3516 (mariadbd)\n     Status: \"Taking your SQL requests now...\"\n      Tasks: 9 (limit: 1133)\n     Memory: 86.2M\n        CPU: 2.201s\n     CGroup: \/system.slice\/mariadb.service\n             \u2514\u25003516 \/usr\/sbin\/mariadbd\n\nAug 21 08:49:47 debian11.kifarunix-demo.com \/etc\/mysql\/debian-start[3536]: Phase 6\/7: Checking and upgrading tables\nAug 21 08:49:47 debian11.kifarunix-demo.com \/etc\/mysql\/debian-start[3536]: Processing databases\nAug 21 08:49:47 debian11.kifarunix-demo.com \/etc\/mysql\/debian-start[3536]: information_schema\nAug 21 08:49:47 debian11.kifarunix-demo.com \/etc\/mysql\/debian-start[3536]: performance_schema\nAug 21 08:49:47 debian11.kifarunix-demo.com \/etc\/mysql\/debian-start[3536]: sys\nAug 21 08:49:47 debian11.kifarunix-demo.com \/etc\/mysql\/debian-start[3536]: sys.sys_config                                     OK\nAug 21 08:49:47 debian11.kifarunix-demo.com \/etc\/mysql\/debian-start[3536]: Phase 7\/7: Running 'FLUSH PRIVILEGES'\nAug 21 08:49:47 debian11.kifarunix-demo.com \/etc\/mysql\/debian-start[3536]: OK\nAug 21 08:49:47 debian11.kifarunix-demo.com \/etc\/mysql\/debian-start[4552]: Checking for insecure root accounts.\nAug 21 08:49:47 debian11.kifarunix-demo.com \/etc\/mysql\/debian-start[4556]: Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables\n<\/code><\/pre>\n\n\n\n<p>You can manage the service via systemctl command.<\/p>\n\n\n\n<p>For example, to stop MariaDB service;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl restart mariadb<\/code><\/pre>\n\n\n\n<p>To stop the service;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl stop mariadb<\/code><\/pre>\n\n\n\n<p>Disable the service from running on system boot;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl disable mariadb<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Securing MariaDB 10.6<\/h3>\n\n\n\n<p>MariaDB comes with a default security script,&nbsp;<strong><code>mysql_secure_installation&nbsp;<\/code><\/strong>that is used to improve the security of MariaDB installation by:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Setting the password for root accounts (if need be).<\/li>\n\n\n\n<li>Disabling remote root login to the databases.<\/li>\n\n\n\n<li>Removing anonymous-user accounts.<\/li>\n\n\n\n<li>Removing the test database, which by default can be accessed by anonymous users.<\/li>\n<\/ul>\n\n\n\n<p>Simply run the command below to launch the script.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql_secure_installation<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">MariaDB Authentication<\/h3>\n\n\n\n<p>The new installations of MariaDB have two secure accounts are created during the installation.<\/p>\n\n\n\n<p>The accounts are&nbsp;<strong><code>root@localhost<\/code><\/strong>&nbsp;and&nbsp;<code><strong>mysql@localhost<\/strong><\/code>.<\/p>\n\n\n\n<p>Both accounts uses either of the&nbsp;<strong><code>unix_socket<\/code><\/strong>&nbsp;and the&nbsp;<strong><code>mysql_native_password<\/code><\/strong>&nbsp;authentication plugins.<\/p>\n\n\n\n<p><code><strong>unix_socket<\/strong><\/code>&nbsp;authentication plugin allows a system&nbsp;<code>root<\/code>&nbsp;user or a&nbsp;<code><strong>user with sudo rights<\/strong><\/code>&nbsp;to login as&nbsp;<code><strong>root@locahost<\/strong><\/code>&nbsp;to MariaDB database without a password.<\/p>\n\n\n\n<p>With&nbsp;<code><strong>unix_socket<\/strong><\/code>&nbsp;authentication plugin, while being a root user, you can simply login by running either of the commands below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql<\/code><\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql -u root<\/code><\/pre>\n\n\n\n<p>Even if you run,&nbsp;<code><strong>mysql -u root -p<\/strong><\/code>, and press ENTER for blank password, you will still login.<\/p>\n\n\n\n<p>As a user with sudo rights, prefix the commands above with&nbsp;<code><strong>sudo<\/strong><\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Enable MariaDB password Authentication<\/h3>\n\n\n\n<p>The&nbsp;<code>mysql_native_password<\/code>&nbsp;plugin is used as a failover for the&nbsp;<code>unix_socket<\/code>&nbsp;plugin. However, the account has an invalid password. To enable password authentication, you need to login to MariaDB as root user as shown above and set the password.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>set password = password(\"P@sSw0Rd123\");<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>flush privileges;\nquit<\/code><\/pre>\n\n\n\n<p>This re-enables the MariaDB password authentication and hence, you can now login as non root or non sudo user.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>koromicha@debian:~$ mysql -u root -p\nEnter password: ENTER PASSWORD<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code> \nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\nYour MariaDB connection id is 57\nServer version: 10.6.4-MariaDB-1:10.6.4+maria~bullseye mariadb.org binary distribution\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nMariaDB [(none)]>\n<\/code><\/pre>\n\n\n\n<p>Similarly, you can login as mysql user;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo -u mysql mysql<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Set Native Password Authentication Method as Default<\/h4>\n\n\n\n<p>To completely disable&nbsp;<code>unix_socke<\/code>t authentication plugin and instead use the&nbsp;<code>msqyl_native_password<\/code>&nbsp;authentication method, simply login to MariaDB and change the authentication plugin for&nbsp;<strong>root<\/strong>&nbsp;user.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD(\"MyPQQSSword\");<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>flush privileges;\nquit<\/code><\/pre>\n\n\n\n<p>Next time you try to login without specifying the password, login will fail.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo mysql -u root<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)<\/code><\/pre>\n\n\n\n<p>That marks the end of our guide on how to install MariaDB on Debian 11.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Other Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-mariadb-10-5-on-freebsd-13\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install MariaDB 10.5 on FreeBSD 13<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-mariadb-10-x-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install MariaDB 10.x on Rocky Linux 8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Follow through this guide to learn how to install MariaDB 10.6 on Debian 11. \u201cMariaDB 10.6&nbsp;is the current&nbsp;stable&nbsp;series of MariaDB. It is an evolution of&nbsp;MariaDB<\/p>\n","protected":false},"author":1,"featured_media":9145,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,299,928],"tags":[3958,3980,3978,3979,3981],"class_list":["post-10147","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-database","category-mariadb","tag-debian-11","tag-debian-11-mariadb","tag-install-mariadb-10-6-on-debian-11","tag-install-mariadb-debian-11","tag-mariadb-11","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10147"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=10147"}],"version-history":[{"count":3,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10147\/revisions"}],"predecessor-version":[{"id":21685,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10147\/revisions\/21685"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/9145"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=10147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=10147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=10147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}