How to Install MySQL 8 on Debian 11

MySQL is an open-source, fast reliable, and flexible relational database management system, typically used with PHP. In this article, we are going to learn how to install MySQL 8 on Debian 11. So, let’s get started.

Pre-requisites :

  • A system with Debian 11 installed and running.

  • root access to the system.

Once you're all set, we'll proceed with MySQL 8 installation and configuration.

Add Repository

Let us begin with adding MySQL Dev apt repository.

apt update

apt -y  install wget

wget https://repo.mysql.com//mysql-apt-config_0.8.18-1_all.deb

dpkg -i mysql-apt-config_0.8.18-1_all.deb

Debian Bullseye is not supported by MySQL. So we will select Debian Buster to get started.

Install MySQL 8

Let's install MySQL 8 using the below commands.

apt update

apt -y install mysql-server

Create Database

Let us begin with creating a Database and a user. We will then grant the required privileges to the user so it can interact with the Database:

CREATE USER 'test_user_crowncloud'@'localhost' IDENTIFIED BY "Password_crowncloud";

CREATE DATABASE test_db_crowncloud;

GRANT ALL PRIVILEGES ON test_db_crowncloud.* TO 'test_user_crowncloud'@'localhost';

FLUSH PRIVILEGES;

EXIT

The above commands will give complete access to the test_db_crowncloud Database to the user est_user_crowncloud.We would suggest using a strong and long password.

Now you have successfully installed MySQL 8 on Debian 11.