MySQL is an open-source relational database management system. Its one of the popular relational management system.
Mysql is commonly installed as part of the popular LAMP or LEMP (Linux, Apache/Nginx, MySQL/MariaDB, PHP/Python/Perl) stack. It implements the relational model and Structured Query Language (SQL) to manage and query data.
In this guide we are going to install mysql 8 on Debian 11.
Related Content
- How to install Mysql Server 8 on OpenSUSE Leap 15.3
- How to install and Configure Mysql Server 8 on Fedora 34/35
- How to install Mysql 8 on Rocky Linux/Centos 8
- How to Install and Set Up mysql 8 on Ubuntu 20.04
- How to run Mysql 8 with Docker and Docker-Compose
- Using Ansible to Install and Initialize Mysql 8 on Centos 8
- Mysql Permissions – Create, Update, Delete Database Users
- Install and Setup Nginx, WordPress and Mysql 8 in Centos 8
- Create an RDS instance in terraform with a Mariadb Example
Table of Content
- Ensuring the server is Up to date
- Set up the repo for mysql 8 installation
- Installing Mysql 8 server
- Starting and enabling mysql service
- Testing mysql installation
1. Ensuring the Server is Up to date
Before proceeding, let us ensure that our debian server is up to date. Use this command to update the server packages:
sudo apt update
sudo apt upgrade -y
Next, let us install common packages that we will need in our tutorial
sudo apt install -y curl vim
2. Set up the repo for mysql 8 installation
Mysql server 8 is not available in the default Debian repositories. The mysql team provides a downloadable .deb
file that will configure the repositories for mysql server 8 installation. Download it with this command:
curl -LO https://dev.mysql.com/get/mysql-apt-config_0.8.20-1_all.deb
You should see an output almost similar to this:
$ curl -LO https://dev.mysql.com/get/mysql-apt-config_0.8.20-1_all.deb % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 35548 100 35548 0 0 104k 0 --:--:-- --:--:-- --:--:-- 104k
Once the download is done, we need to install the downloaded deb file. Use this command to install:
sudo dpkg -i ./mysql-apt-config_0.8.20-1_all.deb
This will open a configuration window prompting you to choose mysql server version and other components such as cluster, shared client libraries, or the MySQL workbench.
For now since we are only interested in the Mysql Server Installation, leave the default (Mysql Server and cluster) settings and click OK to proceed.

This is the output on successful installation and configuration.
$ sudo dpkg -i ./mysql-apt-config_0.8.20-1_all.deb sudo: unable to resolve host debiansrv.citizix.com: No address associated with hostname (Reading database ... 30001 files and directories currently installed.) Preparing to unpack .../mysql-apt-config_0.8.20-1_all.deb ... Unpacking mysql-apt-config (0.8.20-1) over (0.8.20-1) ... Setting up mysql-apt-config (0.8.20-1) ... Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config) Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). OK
3. Installing Mysql 8 server
Now that the repos have been added to include mysql server, we can now install the mysql-server package.
First, refresh the repositories to get the latest from the added repo:
sudo apt update
Then Install Mysql 8 Server using this command:
sudo apt install -y mysql-server
Enter your administrator credentials, and the system will install the MySQL server package, client packages, and database common files.
The installation will prompt you to enter and confirm a root user and password for the MySQL database.

Use this command to check the info of the installed package to confirm that we installed the mysql version that we want:
$ apt-cache policy mysql-server
mysql-server:
Installed: 8.0.27-1debian11
Candidate: 8.0.27-1debian11
Version table:
*** 8.0.27-1debian11 500
500 http://repo.mysql.com/apt/debian bullseye/mysql-8.0 amd64 Packages
100 /var/lib/dpkg/status
4. Starting and enabling mysql service
In debian, Mysql server will be styarted by default. Check the status of the service to confirm that it is actually running:
$ sudo systemctl status mysql
sudo: unable to resolve host debiansrv.citizix.com: No address associated with hostname
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-11-24 04:47:23 UTC; 2min 31s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 15747 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/>
Main PID: 15782 (mysqld)
Status: "Server is operational"
Tasks: 37 (limit: 4626)
Memory: 356.7M
CPU: 911ms
CGroup: /system.slice/mysql.service
└─15782 /usr/sbin/mysqld
Nov 24 04:47:22 debiansrv.citizix.com systemd[1]: Starting MySQL Community Server...
Nov 24 04:47:23 debiansrv.citizix.com systemd[1]: Started MySQL Community Server.
The Active: active (running) since ...
indicates that the service is up and running.
To enable the service to start on reboots, use this command:
sudo systemctl enable mysql
To view the MySQL 8 service log as follows using the journalctl command:
$ sudo journalctl -u mysql -xe
$ sudo tail -f /var/log/mysql/mysqld.log
5. Testing MySQL Installation
Let us check mysql version with this command:
$ mysql -V
mysql Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - GPL)
Now you can Login as the root
user and the password specified above.
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.27 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.27 |
+-----------+
1 row in set (0.00 sec)
mysql>
Conclusion
In this article, we managed to install and test mysql 8 installation on Debian 11.
1 Comment
Pingback: How to install Mysql Server 8 on FreeBSD 13 – Citizix