{"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

This guide provides a step-wise tutorial on how to install MySQL 8 on Debian 11. MySQL<\/a> 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 MySQL 8 Reference Manual<\/a>.<\/p>\n\n\n\n

Installing MySQL 8 on Debian 11<\/h2>\n\n\n\n

Debian 11 doesn’t ship with MySQL 8 on its default repositories.<\/p>\n\n\n\n

apt show mysql-server<\/code><\/pre>\n\n\n\n
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

Install MySQL APT Repository on Debian 11<\/h3>\n\n\n\n

The recommended way to install MySQL 8 is via the MySQL APT repository. <\/p>\n\n\n\n

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

Download MySQL 8 APT repository installer;<\/p>\n\n\n\n

wget https:\/\/repo.mysql.com\/\/mysql-apt-config_0.8.24-1_all.deb<\/code><\/pre>\n\n\n\n

Install MySQL APT repository;<\/p>\n\n\n\n

apt install .\/<\/meta>mysql-apt-config_0.8.24-1_all.deb -y<\/code><\/pre>\n\n\n\n

If prompted, select the repository for debian bullseye <\/strong>and press TAB<\/strong> key to select Ok. Press ENTER to proceed.<\/p>\n\n\n\n

\"Install<\/figure>\n\n\n\n

Next, on the MySQL product, select Ok<\/strong> and press TAB<\/strong> key to select Ok. Press ENTER to proceed to install the repository.<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

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

Run System Update<\/h3>\n\n\n\n

Before you can proceed, update and upgrade your system packages.<\/p>\n\n\n\n

apt update<\/code><\/pre>\n\n\n\n

Next, install MySQL 8 by executing the command below;<\/p>\n\n\n\n

apt install mysql-server<\/code><\/pre>\n\n\n\n

The command installs MySQL 8 and all required package dependency.<\/p>\n\n\n\n

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

During the installation, you are prompted to set MySQL 8 root password;<\/p>\n\n\n\n

\"\"<\/figure><\/a><\/div>\n\n\n\n

Set MySQL 8 default authentication plugin.<\/p>\n\n\n\n

\"\"<\/figure><\/a><\/div>\n\n\n\n

Running MySQL 8 on Debian 11<\/h3>\n\n\n\n

Once installed, MySQL 8 is started and enabled to run on system boot;<\/p>\n\n\n\n

systemctl status mysql<\/code><\/pre>\n\n\n\n
\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
systemctl is-enabled mysql<\/code><\/pre>\n\n\n\n
enabled<\/code><\/pre>\n\n\n\n

You can stop\/start\/restart using the commands below, respectively;<\/p>\n\n\n\n

systemctl stop mysql<\/code><\/pre>\n\n\n\n
systemctl start mysql<\/code><\/pre>\n\n\n\n
systemctl restart mysql<\/code><\/pre>\n\n\n\n

Secure MySQL 8 Installation on Debian 11<\/h3>\n\n\n\n

MySQL ships with a security script called mysql_secure_installation<\/code> that enables you to implement initial security of MySQL installation in the following ways:<\/p>\n\n\n\n