{"id":10145,"date":"2021-08-21T11:35:33","date_gmt":"2021-08-21T08:35:33","guid":{"rendered":"https:\/\/kifarunix.com\/?p=10145"},"modified":"2024-03-18T18:47:33","modified_gmt":"2024-03-18T15:47:33","slug":"install-mysql-8-on-debian-11","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-mysql-8-on-debian-11\/","title":{"rendered":"Install MySQL 8 on Debian 11"},"content":{"rendered":"\n<p>This guide provides a step-wise tutorial on how to install MySQL 8 on Debian 11.&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.mysql.com\/\" target=\"_blank\">MySQL<\/a>&nbsp;is a fast, stable and true multi-user, multi-threaded SQL database server with its main goals being speed, robustness and ease of use. To see a comprehensive description of the features offered by MySQL 8, navigate to&nbsp;<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/mysql-nutshell.html\" target=\"_blank\" rel=\"noreferrer noopener\">MySQL 8 Reference Manual<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing MySQL 8 on Debian 11<\/h2>\n\n\n\n<p>Debian 11 doesn&#8217;t ship with MySQL 8 on its default repositories.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt show mysql-server<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Package: mysql-server\nState: not a real package (virtual)\nN: Can't select candidate version from package mysql-server as it has no candidate\nN: Can't select versions from package 'mysql-server' as it is purely virtual\nN: No packages found<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install MySQL APT Repository on Debian 11<\/h3>\n\n\n\n<p>The recommended way to install MySQL 8 is via the MySQL APT repository. <\/p>\n\n\n\n<p>As a result, you need to install MySQL APT repository on Debian 11. This makes the installation of MySQL 8 a seamless task.<\/p>\n\n\n\n<p>Download MySQL 8 APT repository installer;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/repo.mysql.com\/\/mysql-apt-config_0.8.24-1_all.deb<\/code><\/pre>\n\n\n\n<p>Install MySQL APT repository;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install .\/<meta http-equiv=\"content-type\" content=\"text\/html; charset=utf-8\"><\/meta>mysql-apt-config_0.8.24-1_all.deb -y<\/code><\/pre>\n\n\n\n<p>If prompted, select the repository for <strong>debian bullseye <\/strong>and press <strong>TAB<\/strong> key to select Ok. Press ENTER to proceed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1802\" height=\"527\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/mysql-APT-repos-debian.png\" alt=\"Install MySQL 8 on Debian 11\" class=\"wp-image-17238\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/mysql-APT-repos-debian.png?v=1686764975 1802w, https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/mysql-APT-repos-debian-768x225.png?v=1686764975 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/06\/mysql-APT-repos-debian-1536x449.png?v=1686764975 1536w\" sizes=\"(max-width: 1802px) 100vw, 1802px\" \/><\/figure>\n\n\n\n<p>Next, on the MySQL product, select <strong>Ok<\/strong> and <meta http-equiv=\"content-type\" content=\"text\/html; charset=utf-8\">press <strong>TAB<\/strong> key to select Ok. Press ENTER to proceed to install the repository.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1861\" height=\"462\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/08\/mysql-product-select.png\" alt=\"\" class=\"wp-image-10153\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/08\/mysql-product-select.png?v=1629534711 1861w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/08\/mysql-product-select-768x191.png?v=1629534711 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/08\/mysql-product-select-1536x381.png?v=1629534711 1536w\" sizes=\"(max-width: 1861px) 100vw, 1861px\" \/><\/figure>\n\n\n\n<p>If re-prompted for product selection, do as above and press ENTER to finalize the installation of MySQL APT repository.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Run System Update<\/h3>\n\n\n\n<p>Before you can proceed, 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<p>Next, install MySQL 8 by executing the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install mysql-server<\/code><\/pre>\n\n\n\n<p>The command installs MySQL 8 and all required package dependency.<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>Reading package lists... Done\nBuilding dependency tree... Done\nReading state information... Done\nThe following additional packages will be installed:\n  libaio1 libmecab2 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-client-plugins\n  mysql-community-server mysql-community-server-core psmisc\nThe following NEW packages will be installed:\n  libaio1 libmecab2 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-client-plugins\n  mysql-community-server mysql-community-server-core mysql-server psmisc\n0 upgraded, 14 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 33.4 MB of archives.\nAfter this operation, 282 MB of additional disk space will be used.\nDo you want to continue? [Y\/n] y\n...\n<\/code><\/pre>\n\n\n\n<p>During the installation, you are prompted to set MySQL 8 root password;<\/p>\n\n\n\n<div><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/08\/mysql-8-root.png\" class=\"td-modal-image\"><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1872\" height=\"297\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/08\/mysql-8-root.png\" alt=\"\" class=\"wp-image-10154\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/08\/mysql-8-root.png?v=1629534781 1872w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/08\/mysql-8-root-768x122.png?v=1629534781 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/08\/mysql-8-root-1536x244.png?v=1629534781 1536w\" sizes=\"(max-width: 1872px) 100vw, 1872px\" \/><\/figure><\/a><\/div>\n\n\n\n<p>Set MySQL 8 default authentication plugin.<\/p>\n\n\n\n<div><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/08\/auth-plugin.png\" class=\"td-modal-image\"><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1864\" height=\"531\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/08\/auth-plugin.png\" alt=\"\" class=\"wp-image-10155\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/08\/auth-plugin.png?v=1629534803 1864w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/08\/auth-plugin-768x219.png?v=1629534803 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/08\/auth-plugin-1536x438.png?v=1629534803 1536w\" sizes=\"(max-width: 1864px) 100vw, 1864px\" \/><\/figure><\/a><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Running MySQL 8 on Debian 11<\/h3>\n\n\n\n<p>Once installed, MySQL 8 is started and enabled to run on system boot;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status mysql<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\u25cf mysql.service - MySQL Community Server\n     Loaded: loaded (\/lib\/systemd\/system\/mysql.service; enabled; vendor preset: enabled)\n     Active: active (running) since Sat 2021-08-21 11:10:46 EAT; 30s ago\n       Docs: man:mysqld(8)\n             http:\/\/dev.mysql.com\/doc\/refman\/en\/using-systemd.html\n    Process: 2193 ExecStartPre=\/usr\/share\/mysql-8.0\/mysql-systemd-start pre (code=exited, status=0\/SUCCESS)\n   Main PID: 2228 (mysqld)\n     Status: \"Server is operational\"\n      Tasks: 38 (limit: 1133)\n     Memory: 356.8M\n        CPU: 1.388s\n     CGroup: \/system.slice\/mysql.service\n             \u2514\u25002228 \/usr\/sbin\/mysqld\n\nAug 21 11:10:40 debian11 systemd[1]: Starting MySQL Community Server...\nAug 21 11:10:46 debian11 systemd[1]: Started MySQL Community Server.\n\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl is-enabled mysql<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>enabled<\/code><\/pre>\n\n\n\n<p>You can stop\/start\/restart using the commands below, respectively;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code><meta http-equiv=\"content-type\" content=\"text\/html; charset=utf-8\">systemctl stop mysql<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code><meta http-equiv=\"content-type\" content=\"text\/html; charset=utf-8\">systemctl start mysql<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code><meta http-equiv=\"content-type\" content=\"text\/html; charset=utf-8\">systemctl restart mysql<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Secure MySQL 8 Installation on Debian 11<\/h3>\n\n\n\n<p>MySQL ships with a security script called&nbsp;<code>mysql_secure_installation<\/code>&nbsp;that enables you to implement initial security of MySQL installation in the following ways:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can set a password for root accounts.<\/li>\n\n\n\n<li>You can remove root accounts that are accessible from outside the local host.<\/li>\n\n\n\n<li>You can remove anonymous-user accounts.<\/li>\n\n\n\n<li>You can remove the test database (which by default can be accessed by all users, even anonymous users), and privileges that permit anyone to access databases with names that start with test_.<\/li>\n<\/ul>\n\n\n\n<p>The script can be simply execute by running;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql_secure_installation<\/code><\/pre>\n\n\n\n<p>When run, the script prompts you on whether you want to implement password complexity checks. Accept the choose the strength of the password;<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>VALIDATE PASSWORD COMPONENT can be used to test passwords\nand improve security. It checks the strength of password\nand allows the users to set only those passwords which are\nsecure enough. Would you like to setup VALIDATE PASSWORD component?\n\nPress y|Y for Yes, any other key for No: y\n\nThere are three levels of password validation policy:\n\nLOW    Length &gt;= 8\nMEDIUM Length &gt;= 8, numeric, mixed case, and special characters\nSTRONG Length &gt;= 8, numeric, mixed case, special characters and dictionary                  file\n\nPlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2\n...\n<\/code><\/pre>\n\n\n\n<p>Next, set the root password and accept other prompts to remove anonymous database users, disallow remote root login, remove test databases and reload privileges tables to effect the changes on MySQL.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Checking the Version of MySQL Installed<\/h3>\n\n\n\n<p>You can verify the version of MySQL installed by executing;<\/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 8.0.26 for Linux on x86_64 (MySQL Community Server - GPL)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Logging in to MySQL 8<\/h3>\n\n\n\n<p>You can now connect to MySQL 8 as a root user with the password you just set above.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql -u root -p<\/code><\/pre>\n\n\n\n<p>Once logged in to MySQL, you can as well check the version by executing the command;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql&gt; <strong>SHOW VARIABLES LIKE \"%version%\";<\/strong><\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>+--------------------------+-------------------------------+\n| Variable_name            | Value                         |\n+--------------------------+-------------------------------+\n| admin_tls_version        | TLSv1,TLSv1.1,TLSv1.2,TLSv1.3 |\n| immediate_server_version | 999999                        |\n| innodb_version           | 8.0.26                        |\n| original_server_version  | 999999                        |\n| protocol_version         | 10                            |\n| replica_type_conversions |                               |\n| slave_type_conversions   |                               |\n| tls_version              | TLSv1,TLSv1.1,TLSv1.2,TLSv1.3 |\n| version                  | 8.0.26                        |\n| version_comment          | MySQL Community Server - GPL  |\n| version_compile_machine  | x86_64                        |\n| version_compile_os       | Linux                         |\n| version_compile_zlib     | 1.2.11                        |\n+--------------------------+-------------------------------+\n13 rows in set (0.06 sec)\n\nmysql&gt;\n<\/code><\/pre>\n\n\n\n<p>There you go.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Related Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-mariadb-10-6-on-debian-11\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install MariaDB 10.6 on Debian 11<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-mysql-8-on-ubuntu-20-04\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install MySQL 8 on Ubuntu 20.04<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-mysql-8-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install MySQL 8 on Rocky Linux 8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide provides a step-wise tutorial on how to install MySQL 8 on Debian 11.&nbsp;MySQL&nbsp;is a fast, stable and true multi-user, multi-threaded SQL database server<\/p>\n","protected":false},"author":1,"featured_media":10150,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,299,929],"tags":[3983,3985,3987,3982,3984],"class_list":["post-10145","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-database","category-mysql","tag-debian-11-mysql-8","tag-debian-11-mysql-8-repositories","tag-install-mysql-8","tag-install-mysql-8-debian-11","tag-mysql-8-install-debian-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\/10145"}],"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=10145"}],"version-history":[{"count":5,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10145\/revisions"}],"predecessor-version":[{"id":21683,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10145\/revisions\/21683"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/10150"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=10145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=10145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=10145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}