This guide provides a step-wise tutorial on how to install MySQL 8 on Debian 11. MySQL 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.
Install MySQL 8 on Debian 11
Debian 11 doesn’t ship with MySQL 8 on its default repositories.
apt show mysql-server
Package: mysql-server
State: not a real package (virtual)
N: Can't select candidate version from package mysql-server as it has no candidate
N: Can't select versions from package 'mysql-server' as it is purely virtual
N: No packages found
Install MySQL APT Repository on Debian 11
The recommended way to install MySQL 8 on Debian 11 is via the MySQL APT repository.
As a result, you need to install MySQL APT repository on Debian 11. This makes the installation of MySQL 8 a seamless task.
Download MySQL 8 APT repository installer;
wget https://repo.mysql.com//mysql-apt-config_0.8.18-1_all.deb
Install MySQL APT repository;
apt install ./mysql-apt-config_0.8.18-1_all.deb -y
Please note that as of this writing, the repository is not supported for Debian 11 bullseye.
If prompted, select the repository for debian buster and press TAB key to select Ok. Press ENTER to proceed.
Next, on the MySQL product, select Ok and press TAB key to select Ok. Press ENTER to proceed to install the repository.

If re-prompted for product selection, do as above and press ENTER to finalize the installation of MySQL APT repository.
Run System Update
Before you can proceed, update and upgrade your system packages.
apt update
Next, install MySQL 8 on Debian 11 by executing the command below;
apt install mysql-server
The command installs MySQL 8 and all required package dependency.
Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: libaio1 libmecab2 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-client-plugins mysql-community-server mysql-community-server-core psmisc The following NEW packages will be installed: libaio1 libmecab2 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-client-plugins mysql-community-server mysql-community-server-core mysql-server psmisc 0 upgraded, 14 newly installed, 0 to remove and 0 not upgraded. Need to get 33.4 MB of archives. After this operation, 282 MB of additional disk space will be used. Do you want to continue? [Y/n] y ...
During the installation, you are prompted to set MySQL 8 root password;
Set MySQL 8 default authentication plugin.
Running MySQL 8 on Debian 11
Once installed, MySQL 8 is started and enabled to run on system boot;
systemctl status mysql
● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2021-08-21 11:10:46 EAT; 30s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 2193 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 2228 (mysqld) Status: "Server is operational" Tasks: 38 (limit: 1133) Memory: 356.8M CPU: 1.388s CGroup: /system.slice/mysql.service └─2228 /usr/sbin/mysqld Aug 21 11:10:40 debian11 systemd[1]: Starting MySQL Community Server... Aug 21 11:10:46 debian11 systemd[1]: Started MySQL Community Server.
systemctl is-enabled mysql
enabled
You can stop/start/restart using the commands below, respectively;
systemctl stop mysql
systemctl start mysql
systemctl restart mysql
Secure MySQL 8 Installation on Debian 11
MySQL ships with a security script called mysql_secure_installation
that enables you to implement initial security of MySQL installation in the following ways:
- You can set a password for root accounts.
- You can remove root accounts that are accessible from outside the local host.
- You can remove anonymous-user accounts.
- 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_.
The script can be simply execute by running;
mysql_secure_installation
When run, the script prompts you on whether you want to implement password complexity checks. Accept the choose the strength of the password;
VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component? Press y|Y for Yes, any other key for No: y There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2 ...
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.
Checking the Version of MySQL Installed
You can verify the version of MySQL installed by executing;
mysql -V
mysql Ver 8.0.26 for Linux on x86_64 (MySQL Community Server - GPL)
Logging in to MySQL 8
You can now connect to MySQL 8 as a root user with the password you just set above.
mysql -u root -p
Once logged in to MySQL, you can as well check the version by executing the command;
mysql> SHOW VARIABLES LIKE "%version%";
+--------------------------+-------------------------------+ | Variable_name | Value | +--------------------------+-------------------------------+ | admin_tls_version | TLSv1,TLSv1.1,TLSv1.2,TLSv1.3 | | immediate_server_version | 999999 | | innodb_version | 8.0.26 | | original_server_version | 999999 | | protocol_version | 10 | | replica_type_conversions | | | slave_type_conversions | | | tls_version | TLSv1,TLSv1.1,TLSv1.2,TLSv1.3 | | version | 8.0.26 | | version_comment | MySQL Community Server - GPL | | version_compile_machine | x86_64 | | version_compile_os | Linux | | version_compile_zlib | 1.2.11 | +--------------------------+-------------------------------+ 13 rows in set (0.06 sec) mysql>
There you go.
That marks the end of our guide on how to install MySQL 8 on Debian 11.
Related Tutorials
Install MariaDB 10.6 on Debian 11
Install MySQL 8 on Ubuntu 20.04
Install MySQL 8 on Rocky Linux 8