{"id":17195,"date":"2023-06-14T01:08:47","date_gmt":"2023-06-13T22:08:47","guid":{"rendered":"https:\/\/kifarunix.com\/?p=17195"},"modified":"2024-03-10T09:57:08","modified_gmt":"2024-03-10T06:57:08","slug":"install-mariadb-10-on-debian-12","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-mariadb-10-on-debian-12\/","title":{"rendered":"Install MariaDB 10 on Debian 12"},"content":{"rendered":"\n<p>Follow through this guide to learn how to install MariaDB 10 on Debian 12. \u201c<em><a href=\"https:\/\/mariadb.com\/kb\/en\/changes-improvements-in-mariadb-11-0\/\" target=\"_blank\" rel=\"noreferrer noopener\">MariaDB 10<\/a>&nbsp;is the new major release series of MariaDB. It ships with several entirely&nbsp;<a href=\"https:\/\/mariadb.com\/kb\/en\/changes-improvements-in-mariadb-11-0\/\" target=\"_blank\" rel=\"noreferrer noopener\">new features and improvements<\/a>&#8220;<\/em>.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#installing-maria-db-10-on-debian-12\">Installing MariaDB 10 on Debian 12<\/a><ul><li><a href=\"#run-system-update\">Run System Update<\/a><\/li><li><a href=\"#install-maria-db-10\">Install MariaDB 10<\/a><ul><li><a href=\"#verify-the-maria-db-installed-version\">Verify the MariaDB installed version<\/a><\/li><li><a href=\"#running-maria-db-10-on-debian-12\">Running MariaDB 10 on Debian 12<\/a><\/li><\/ul><\/li><li><a href=\"#securing-maria-db-10\">Securing MariaDB 10<\/a><\/li><li><a href=\"#maria-db-authentication\">MariaDB Authentication<\/a><\/li><li><a href=\"#enable-maria-db-password-authentication\">Enable MariaDB password Authentication<\/a><ul><li><a href=\"#set-native-password-authentication-method-as-default\">Set Native Password Authentication Method as Default<\/a><\/li><\/ul><\/li><li><a href=\"#other-tutorials\">Other Tutorials<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-maria-db-10-on-debian-12\">Installing MariaDB 10 on Debian 12<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"run-system-update\">Run System Update<\/h3>\n\n\n\n<p>Assuming that you are installing MariaDB 10 on a newly installed Debian 12, update and upgrade your system packages.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt update<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-maria-db-10\">Install MariaDB 10<\/h3>\n\n\n\n<p>One of the easiest ways to install MariaDB is via the use of their MariaDB package repositories.<\/p>\n\n\n\n<p>The default repos for Debian 10\/Debian 12 do provide MariaDB 10 packages.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt show mariadb-server<\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nPackage: mariadb-server\nVersion: 1:10.11.3-1\nPriority: optional\nSection: database\nSource: mariadb\nMaintainer: Debian MySQL Maintainers <pkg-mysql-maint@lists.alioth.debian.org>\nInstalled-Size: 55.2 MB\nProvides: virtual-mysql-server\nPre-Depends: adduser (>= 3.40), debconf, mariadb-common (>= 1:10.11.3-1)\n...\n<\/code><\/pre>\n\n\n\n<p>Thus, install MariaDB 10 by running the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt install mariadb-server<\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nReading package lists... Done\nBuilding dependency tree... Done\nReading state information... Done\nThe following additional packages will be installed:\n  galera-4 gawk libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdaxctl1 libdbd-mariadb-perl libdbi-perl libfcgi-bin libfcgi-perl libfcgi0ldbl\n  libhtml-template-perl libmariadb3 libndctl6 libpmem1 libsigsegv2 libterm-readkey-perl liburing2 mariadb-client mariadb-client-core mariadb-common\n  mariadb-plugin-provider-bzip2 mariadb-plugin-provider-lz4 mariadb-plugin-provider-lzma mariadb-plugin-provider-lzo mariadb-plugin-provider-snappy mariadb-server-core\n  mysql-common pv rsync socat\nSuggested packages:\n  gawk-doc libmldbm-perl libnet-daemon-perl libsql-statement-perl libipc-sharedcache-perl mailx mariadb-test netcat-openbsd doc-base python3-braceexpand\nThe following NEW packages will be installed:\n  galera-4 gawk libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdaxctl1 libdbd-mariadb-perl libdbi-perl libfcgi-bin libfcgi-perl libfcgi0ldbl\n  libhtml-template-perl libmariadb3 libndctl6 libpmem1 libsigsegv2 libterm-readkey-perl liburing2 mariadb-client mariadb-client-core mariadb-common\n  mariadb-plugin-provider-bzip2 mariadb-plugin-provider-lz4 mariadb-plugin-provider-lzma mariadb-plugin-provider-lzo mariadb-plugin-provider-snappy mariadb-server\n  mariadb-server-core mysql-common pv rsync socat\n0 upgraded, 32 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 18.9 MB of archives.\nAfter this operation, 194 MB of additional disk space will be used.\nDo you want to continue? [Y\/n] y\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"verify-the-maria-db-installed-version\">Verify the MariaDB installed version<\/h4>\n\n\n\n<p>MariaDB 10 deprecates the use of <strong><code>mysql<\/code><\/strong> command line tool and replaces it with <code>mariadb<\/code>.<\/p>\n\n\n\n<p>As much as you can still be able to use mysql command, you will get some deprecation warnings.<\/p>\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\">mariadb -V<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">mariadb  Ver 15.1 Distrib 10.11.3-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"running-maria-db-10-on-debian-12\">Running MariaDB 10 on Debian 12<\/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\">systemctl status mariadb<\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n\u25cf mariadb.service - MariaDB 10.11.3 database server\n     Loaded: loaded (\/lib\/systemd\/system\/mariadb.service; enabled; preset: enabled)\n     Active: active (running) since Wed 2023-06-14 00:57:58 EAT; 32s ago\n       Docs: man:mariadbd(8)\n             https:\/\/mariadb.com\/kb\/en\/library\/systemd\/\n   Main PID: 8148 (mariadbd)\n     Status: \"Taking your SQL requests now...\"\n      Tasks: 14 (limit: 2285)\n     Memory: 92.3M\n        CPU: 435ms\n     CGroup: \/system.slice\/mariadb.service\n             \u2514\u25008148 \/usr\/sbin\/mariadbd\n\nJun 14 00:57:57 bookworm mariadbd[8148]: 2023-06-14  0:57:57 0 [Note] InnoDB: Loading buffer pool(s) from \/var\/lib\/mysql\/ib_buffer_pool\nJun 14 00:57:57 bookworm mariadbd[8148]: 2023-06-14  0:57:57 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.\nJun 14 00:57:57 bookworm mariadbd[8148]: 2023-06-14  0:57:57 0 [Note] Server socket created on IP: '127.0.0.1'.\nJun 14 00:57:57 bookworm mariadbd[8148]: 2023-06-14  0:57:57 0 [Note] InnoDB: Buffer pool(s) load completed at 230614  0:57:57\nJun 14 00:57:57 bookworm mariadbd[8148]: 2023-06-14  0:57:57 0 [Note] \/usr\/sbin\/mariadbd: ready for connections.\nJun 14 00:57:57 bookworm mariadbd[8148]: Version: '10.11.3-MariaDB-1'  socket: '\/run\/mysqld\/mysqld.sock'  port: 3306  Debian 12\nJun 14 00:57:58 bookworm systemd[1]: Started mariadb.service - MariaDB 10.11.3 database server.\nJun 14 00:57:58 bookworm \/etc\/mysql\/debian-start[8166]: Upgrading MySQL tables if necessary.\nJun 14 00:57:58 bookworm \/etc\/mysql\/debian-start[8177]: Checking for insecure root accounts.\nJun 14 00:57:58 bookworm \/etc\/mysql\/debian-start[8181]: 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 start MariaDB service;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl start mariadb<\/pre>\n\n\n\n<p>For example, to restart MariaDB service;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl restart mariadb<\/pre>\n\n\n\n<p>To stop the service;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl stop mariadb<\/pre>\n\n\n\n<p>Disable the service from running on system boot;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl disable mariadb<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"securing-maria-db-10\">Securing MariaDB 10<\/h3>\n\n\n\n<p>MariaDB comes with a default security script,&nbsp;<strong><code>mariadb-secure-installation<\/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\">mariadb-secure-installation<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"maria-db-authentication\">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\">mariadb<\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mariadb -u root<\/pre>\n\n\n\n<p>Even if you run,&nbsp;<code><strong>mariadb -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<p>For example, you can login as mysql user;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -u mysql mariadb<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"enable-maria-db-password-authentication\">Enable MariaDB password Authentication<\/h3>\n\n\n\n<p>With the two privileged accounts, <strong><code>root@localhost<\/code><\/strong> and <strong><code>mysql@localhost<\/code><\/strong>, anyone with access to it can login to MariaDB.<\/p>\n\n\n\n<p>It is not recommended to leave such user accounts with no password and all privileges, as this can pose a significant security risk to your database.<\/p>\n\n\n\n<p>The two accounts above uses <code>mysql_native_password<\/code> plugin by default;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mariadb<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>select User,Host,plugin from mysql.user;<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n+-------------+-----------+-----------------------+\n| User        | Host      | plugin                |\n+-------------+-----------+-----------------------+\n<strong>| mariadb.sys | localhost | mysql_native_password |\n| root        | localhost | mysql_native_password |\n| mysql       | localhost | mysql_native_password |<\/strong>\n+-------------+-----------+-----------------------+\n3 rows in set (0.002 sec)\n\nMariaDB [(none)]>\n<\/code><\/pre>\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. Even if you have setup a password using MariaDB secure installation script, you can still login as those accounts without a password.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>show grants for root@localhost;<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Grants for root@localhost                                                                                                                                                 |\n+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` IDENTIFIED VIA mysql_native_password USING '*9C6C35530EE4427B07D2FA4F9E119C3915D18940' OR unix_socket WITH GRANT OPTION |\n| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION                                                                                                             |\n+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n2 rows in set (0.000 sec)\n\nMariaDB [(none)]>\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>show grants for mysql@localhost;<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n+------------------------------------------------------------------------------------------------------------------------------------------+\n| Grants for mysql@localhost                                                                                                               |\n+------------------------------------------------------------------------------------------------------------------------------------------+\n| GRANT ALL PRIVILEGES ON *.* TO `mysql`@`localhost` IDENTIFIED VIA mysql_native_password USING 'invalid' OR unix_socket WITH GRANT OPTION |\n+------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.000 sec)\n\nMariaDB [(none)]>\n<\/code><\/pre>\n\n\n\n<p>As you can see above, we had already set the password for root user using the mysql_secure_installation command. But mysql user account has invalid password.<\/p>\n\n\n\n<p>Thus, enable password authentication.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ALTER USER root@localhost identified by 'myStr0nP@ssW0rd';<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ALTER USER mysql@localhost identified by 'myStr0nP@ssW0rd2';<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">flush privileges;\nquit<\/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\">mariadb<\/pre>\n\n\n\n<p>Or;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -u mysql mariadb<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\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>Provide a password to be able to login;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mariadb -u root -p<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nEnter password: \nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\nYour MariaDB connection id is 37\nServer version: 10.11.3-MariaDB-1 Debian 12\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<h4 class=\"wp-block-heading\" id=\"set-native-password-authentication-method-as-default\">Set Native Password Authentication Method as Default<\/h4>\n\n\n\n<p>When you set the password above, it completely disables&nbsp;<code>unix_socke<\/code>t authentication plugin and instead use the&nbsp;<code>msqyl_native_password<\/code>&nbsp;authentication method;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">show grants for root@localhost;<\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n+----------------------------------------------------------------------------------------------------------------------------------------+\n| Grants for root@localhost                                                                                                              |\n+----------------------------------------------------------------------------------------------------------------------------------------+\n| GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` IDENTIFIED BY PASSWORD '*73E1DDB4DA8B34D3080B082A8DFC863A56285DD4' WITH GRANT OPTION |\n| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION                                                                          |\n+----------------------------------------------------------------------------------------------------------------------------------------+\n2 rows in set (0.000 sec)\n\nMariaDB [(none)]>\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>show grants for mysql@localhost;<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n+-----------------------------------------------------------------------------------------------------------------------------------------+\n| Grants for mysql@localhost                                                                                                              |\n+-----------------------------------------------------------------------------------------------------------------------------------------+\n| GRANT ALL PRIVILEGES ON *.* TO `mysql`@`localhost` IDENTIFIED BY PASSWORD '*4C8C1832BBF14A360C2F70EA14CBD912AE0AF280' WITH GRANT OPTION |\n+-----------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.000 sec)\n\nMariaDB [(none)]>\n<\/code><\/pre>\n\n\n\n<p>That marks the end of our guide on installing MariaDB 10 on Debian 12.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"other-tutorials\">Other Tutorials<\/h3>\n\n\n\n<p>You can check our <a href=\"https:\/\/kifarunix.com\/?s=mariadb\" target=\"_blank\" rel=\"noreferrer noopener\">other MySQL\/MariaDB related tutorials<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Follow through this guide to learn how to install MariaDB 10 on Debian 12. \u201cMariaDB 10&nbsp;is the new major release series of MariaDB. It ships<\/p>\n","protected":false},"author":10,"featured_media":17218,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[299,121,928],"tags":[6859,6880,6882,6879,6883,6881],"class_list":["post-17195","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-database","category-howtos","category-mariadb","tag-debian-12","tag-debian-12-mariadb","tag-install-debian-12-on-mariadb","tag-install-mariadb-debian-12","tag-mariadb-10","tag-mariadb-10-debian-12","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\/17195"}],"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\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=17195"}],"version-history":[{"count":4,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/17195\/revisions"}],"predecessor-version":[{"id":20782,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/17195\/revisions\/20782"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/17218"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=17195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=17195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=17195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}