{"id":2753,"date":"2020-12-19T17:37:26","date_gmt":"2020-12-19T17:37:26","guid":{"rendered":"https:\/\/linuxways.net\/?p=2753"},"modified":"2020-12-19T18:12:15","modified_gmt":"2020-12-19T18:12:15","slug":"how-to-install-mariadb-on-ubuntu-20-04-lts","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-mariadb-on-ubuntu-20-04-lts\/","title":{"rendered":"How to Install MariaDB on Ubuntu 20.04 LTS"},"content":{"rendered":"<p>MariaDB is one of the most widely used and open-source database management systems. MariaDB is considered as a replacement for MySQL and has much more features and capabilities that you cannot find in MySQL. In our previous posts, we have explained how to install MariaDB in <a href=\"https:\/\/linuxways.net\/de\/debian\/how-to-install-mariadb-on-debian-10\/\">Debian<\/a>, <a href=\"https:\/\/linuxways.net\/de\/mint\/how-to-install-mariadb-on-linux-mint-20\/\">Mint<\/a>, and <a href=\"https:\/\/linuxways.net\/de\/centos\/how-to-install-mariadb-on-centos-8\/\">CentOS<\/a>. This post will be about explaining the installation of MariaDB on <strong>Ubuntu <\/strong>20.04 LTS (Focal Fossa). There are the following two methods to install MariaDB:<\/p>\n<ul>\n<li>Through Ubuntu Repository<\/li>\n<li>Through MariaDB Repository<\/li>\n<\/ul>\n<p>The first method installs the older version of MariaDB (10.3) through Ubuntu Repository while the latter installs the latest version of MariaDB (10.5) through MariaDB Repository.<\/p>\n<h2>Prerequisites<\/h2>\n<ul>\n<li>Ubuntu 20.04 LTS system<\/li>\n<li>User with sudo privileges<\/li>\n<\/ul>\n<h2>Installing MariaDB on Ubuntu through Ubuntu Repository<\/h2>\n<p>MariaDB\u2019s version <strong>10.3<\/strong> is available in the official repositories of Ubuntu distribution. Therefore, you can easily install it via apt. Following are the steps for the installation of MariaDB on Ubuntu.<\/p>\n<h4>1. Update package index<\/h4>\n<p>In order to install MariaDB, first update the package index. To do so, open the Terminal through the <strong>Ctrl+Alt+T<\/strong> shortcut and then execute this command:<\/p>\n<pre>$ sudo apt update<\/pre>\n<h4>2. Install MariaDB<\/h4>\n<p>Then install MariaDB as follows:<\/p>\n<pre>$ sudo apt install mariadb-server<\/pre>\n<p>After running the installation command, the system will ask if you want to continue the installation by prompting you with the <strong>y\/n<\/strong> option. Hit <strong>y<\/strong> to carry on the installation process.<\/p>\n<h4>3. Verify Installation<\/h4>\n<p>Once the installation of MariaDB is completed, you can verify it as follows:<\/p>\n<pre>$ mariadb --version<\/pre>\n<p>This command will output the version of MariaDB on your system which verifies that MariaDB is successfully installed. In the bellow output, you can see the installed version of MariaDB is <strong>10.3.25.<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"932\" height=\"63\" class=\"wp-image-2754\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/mariadb-version-10-3.png\" alt=\"MariaDB version 10.3\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/mariadb-version-10-3.png 932w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/mariadb-version-10-3-300x20.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/mariadb-version-10-3-768x52.png 768w\" sizes=\"auto, (max-width: 932px) 100vw, 932px\" \/><\/p>\n<h2>Installing MariaDB on Ubuntu through MariaDB Repository<\/h2>\n<p>MariaDB&#8217;s latest version <strong>10.5<\/strong> is available in the official MariaDB repository. Therefore, in order to install it, you will have to first add the MariaDB repository to your apt sources and then install it. Below are the steps to install MariaDB <strong>10.5 <\/strong>on Ubuntu.<\/p>\n<h4>1. Install Pre-requisites<\/h4>\n<p>Install software-properties-common package through the following command in Terminal:<\/p>\n<pre>$ sudo apt-get install software-properties-common<\/pre>\n<h4>2. Add repository key<\/h4>\n<p>Then run this command to add the GPG key used to sign the MariaDB package:<\/p>\n<pre>$ sudo apt-key adv --fetch-keys 'https:\/\/mariadb.org\/mariadb_release_signing_key.asc'<\/pre>\n<h4>3. Add MariaDB repository<\/h4>\n<p>Now add MariaDB repository to your apt sources using the following command:<\/p>\n<pre>$ sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] <a href=\"http:\/\/mirror.biznetgio.com\/mariadb\/repo\/10.5\/ubuntu\">http:\/\/mirror.biznetgio.com\/mariadb\/repo\/10.5\/ubuntu<\/a> focal main'<\/pre>\n<h4>4. Update package index<\/h4>\n<p>Then update the packages index to include the MariaDB repository. Use the following command to do so:<\/p>\n<pre>$ sudo apt update<\/pre>\n<h4>5. Install MariaDB<\/h4>\n<p>Once the packages list is updated with the MariaDB repository, you can install MariaDB as follows:<\/p>\n<pre>$ sudo apt install mariadb-server<\/pre>\n<p>After running the installation command, the system will ask if you want to continue the installation by prompting you with the <strong>y\/n<\/strong> option. Hit <strong>y<\/strong> to carry on the installation process.<\/p>\n<h4>6. Verify Installation<\/h4>\n<p>Once the installation of MariaDB is completed, you can verify it as follows:<\/p>\n<pre>$ mariadb --version<\/pre>\n<p>This command will output the version of MariaDB on your system which verifies that MariaDB is successfully installed. In the bellow output, you can see the installed version of MariaDB is <strong>10.5.8 (latest version)<\/strong>. <img loading=\"lazy\" decoding=\"async\" width=\"921\" height=\"62\" class=\"wp-image-2755\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/mariadb-versoin-10-5.png\" alt=\"MariaDB versoin 10.5\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/mariadb-versoin-10-5.png 921w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/mariadb-versoin-10-5-300x20.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/mariadb-versoin-10-5-768x52.png 768w\" sizes=\"auto, (max-width: 921px) 100vw, 921px\" \/><\/p>\n<h3>Securing MariaDB<\/h3>\n<p>Now the next step after the installation will be to secure the MariaDB server. We will do this by running a script mysql_secure_installation available on the Linux system. This script allows you to configure passwords for root, disable root login remotely, remove root anonymous user accounts and test database, etc.<\/p>\n<p>To configure the security settings for MariaDB, run the script as follows:<\/p>\n<pre>$ sudo mysql_secure_installation<\/pre>\n<p>After running the above script, you will be prompted for the various questions. It will ask you to provide your root password for MariaDB. As we have not configured it yet, therefore press <strong>Enter<\/strong>. Then it will ask if you want to configure a root password, hit <strong>y<\/strong>, and then enter the password and confirm by re-entering it.<\/p>\n<h2><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"524\" class=\"wp-image-2756\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/securing-mariadb.png\" alt=\"Securing MariaDB\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/securing-mariadb.png 728w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/securing-mariadb-300x216.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/h2>\n<p>Then for all the subsequent questions, hit y as can be seen in the following screenshot.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"766\" height=\"787\" class=\"wp-image-2757\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/mysql_secure_installation.png\" alt=\"mysql_secure_installation\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/mysql_secure_installation.png 766w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/mysql_secure_installation-292x300.png 292w\" sizes=\"auto, (max-width: 766px) 100vw, 766px\" \/><\/p>\n<h2>Verify MariaDB Service<\/h2>\n<p>MariaDB service starts running automatically after the installation is completed. To verify if the MariaDB service is running fine without any issues, run the following command in Terminal:<\/p>\n<pre>$ sudo systemctl status mariadb<\/pre>\n<p>The following output confirms the MariaDB server is active and running.<\/p>\n<h2><img loading=\"lazy\" decoding=\"async\" width=\"922\" height=\"172\" class=\"wp-image-2758\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/status-of-mariadb-service.png\" alt=\"Status of MariaDB service\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/status-of-mariadb-service.png 922w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/status-of-mariadb-service-300x56.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/status-of-mariadb-service-768x143.png 768w\" sizes=\"auto, (max-width: 922px) 100vw, 922px\" \/><\/h2>\n<p>If the MariaDB service does not run automatically, you can start it manually as follows:<\/p>\n<pre>$ sudo systemctl start mariadb<\/pre>\n<h2>Connecting to MariaDB<\/h2>\n<p>Now try connecting to the MariaDB server as a root user. Run the following command to do so:<\/p>\n<pre><strong>$ sudo mysql -u root -p<\/strong><\/pre>\n<p>You will be prompted to enter the root for MariaDB password (that you have configured earlier). Once you entered the password, you will be connected to the MariaDB database. If you have successfully logged in, you will be seeing something that looks similar to the following:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"802\" height=\"326\" class=\"wp-image-2759\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/testing-connection-to-mariadb.png\" alt=\"Testing Connection to MariaDB\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/testing-connection-to-mariadb.png 802w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/testing-connection-to-mariadb-300x122.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/testing-connection-to-mariadb-768x312.png 768w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/p>\n<h2>Uninstalling MariaDB<\/h2>\n<p>In case, you want to completely remove MariaDB from your system, you can do so easily using the following command in Terminal:<\/p>\n<pre>$ sudo apt-get purge mariadb-server<\/pre>\n<p>After running the purge command, the system will ask if you want to continue the process by providing you with the <strong>y\/n<\/strong> option. Hit <strong>y<\/strong> to carry on the uninstallation process.<\/p>\n<p>Then remove the packages that were automatically installed to satisfy dependencies for MariaDB. Run the following command to do so:<\/p>\n<pre>$ sudo apt autoremove<\/pre>\n<p>That is all there is to it! In this post, we have explained the installation of MariaDB on Ubuntu 20.04 LTS system using two different methods. Then we have explained how to secure it by configuring some security options and then, in the end, we have tested the connection to MariaDB. By following the above simple steps, you can easily setup MariaDB on your ubuntu system. For more information, visit MariaDB&#8217;s official <a href=\"https:\/\/mariadb.com\/kb\/en\/documentation\/\">documentation<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>MariaDB is one of the most widely used and open-source database management systems. MariaDB is considered as a replacement for MySQL and has much more features and capabilities&hellip;<\/p>","protected":false},"author":4,"featured_media":2761,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[114,100],"class_list":["post-2753","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-mariadb-2","tag-ubuntu-20-04"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/2753","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=2753"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/2753\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/2761"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=2753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=2753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=2753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}