Install MySQL 8 Debian. In this documentation, we will share how to install MySQL 8.0 Debian 11. Mysql is a system used for database management or better known as Database. We have discussed the actual database in the previous discussion, namely the Install PhpMyadmin Latest Ubuntu 20.04 Apache2. Mysql is one of the LAMP (Linux, Apache, MySQL, PHP/Python/Perl) which is familiar to us.
Specifically for this tutorial, we will discuss MySQL more deeply, and the MySQL that will be installed is MySQL with the latest version, namely 8.0 on the Debian 11 operating system. MySQL is indispensable in managing web or applications in every implementation.
MySQL itself is one of the most commonly used Database Management Systems that uses the concept of a relational database and has a client/server architecture. For the implementation, MySQL can actually be installed on several OS such as Windows, CentOS and Ubuntu. But for this documentation we use Debian 11 OS.

Precondition
To be able to try the Tutorial Install MySQL 8.0 Debian 11, you need
- One Debian 11 server, With root access.
- RAM 4 GB
- 2 CPU
Install MySQL 8.0 Debian 11
Here we will explain the steps to Install MySQL 8.0 Debian 11 at once with a configuration method. Not only that, we will discuss how to name
Step 1: Update the MySQL 8 Debian 11 Server (Install MySQL 8 Debian)
Before starting, you are required to do a server update first, this step is required to install a new server so that all packages or services that are on the Debian 11 OS are updated or updated.
apt update
Step 2: Install GnuPG Package
GnuPG allows you to encrypt and sign your data and communications. GnuPG, also known as GPG , is a command line tool with features for easy integration with other applications. This is very necessary for you to install the MySQL 8.0 repository
apt install gnupg -y
Step 3: Add MySQL Repository (Install MySQL 8 Debian)
Maybe for those of you who have often used Linux, you must be familiar with the Repo or Repository on Linux. A repository is a storage location where your system fetches and installs OS updates and applications. Each repository is a collection of software hosted on a remote server and intended to be used to install and update software packages on Linux systems. When you run commands like “sudo apt update” or “sudo apt upgrade”, you may be pulling package information and package updates from some of these repositories.
To download the repository using the wget service, if there is no wget on the server, it must be downloaded first. Perform the following command
apt install wget -y
After that download the MySQL repo, follow the following command.
wget https://repo.mysql.com//mysql-apt-config_0.8.13-1_all.deb
Install the downloaded repo using the following command
dpkg -i mysql-apt-config_0.8.13-1_all.deb
Note: If when running the dpkg -i command above, an error like this occurs:

This happens because the PATH /usr/local/sbin/, /usr/sbin/ and /sbin have not been entered in the root of Debian. Follow these steps to add the PATH.
Go to file .basrc
nano /root/.bashrc
Then add the following code
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
After that reboot or restart your server
systemctl reboot
If the server is alive again, do the remote again and install the previously downloaded Repo
dpkg -i mysql-apt-config*
During the package installation process, you will be asked to configure the mysql-apt-config repository. In this configuration you are asked to select the MySQL server version and other packages to be installed. After you finish selecting press Enter or select OK and Enter.

After adding the MySQL APT repository, update the Debian server package and Install MySQL Server
apt update
apt install mysql-server
During the installation process, you will receive a notification asking you to enter the root user password for MySQL. Enter a secure password for your root User password.

When finished, then press Enter
MySQL will tell you about the SHA256-based authentication system used by MySQL. In this step you can confirm by selecting OK and Enter

And select the default Authentication System (RECOMMENDED) in the MySQL configuration. For this configuration we use the default MySQL settings, then press Enter to complete the installation

Now the installation process is complete. MySQL Server on Systemd is running automatically when the installation is complete. To ensure that the MySQL Server service is running and active, you can use the following command.
systemctl status mysql
By using this command we can see the status of MySQL Action (running)

There are several MySQL Server service commands that you need to know such as (start, restart, stop, and reload). Use the following command.
systemctl start mysql
systemctl restart mysql
systemctl stop mysql
systemctl reload mysql
Step 4: Securing MySQL on Debian 11 (Install MySQL 8 Debian)
At the beginning of every new MySQL installation, the authentication used is still the default which makes the database security less secure and to increase the security of the MySQL server, you can run the following command to ask you which action to take for the security of the MySQL server.( Install MySQL 8.0 Debian 11 )
mysql_secure_installation
- Enter the password you set during MySQL installation

- And you will be given the choice to use the VALIDATE PASSWORD component, you can choose y (for Yes) or n (for No) to use or not use it, here we do not use the plugin and choose n (for No).
- Then you will also be asked to choose whether to change the password or not. Select Y (For Yes).
- Enter, and enter your new password. Make sure the password you use is secure, with a minimum of 8 characters.
- Next to Remove anonymous users, Disallow root remote, remove test database and reload database select Y (For Yes)

Step 5: Testing MySQL Server (Install MySQL 8 Debian)
After we install and secure the MySQL server, you can start to use the MySQL Database to store data for the Website System or application. There are several commands that you can use to access, create databases and create users for your MySQL Server. For the first step we will try to access MySQL by using the following command.
mysql -u root -p
Then enter the password that you changed when securing MySQL Server

If you have entered the MySQL System, to view the Database use the following command.
SHOW DATABASE;
To create a database you can use the following command
CREATE DATABASE dixmata;
KESIMPULAN
That’s the documentation for Installing MySQL 8.0 Debian 11. There are several steps we can learn from how to enter the MySQL repo, download, install to access the MySQL database. If you want to ask can be done in the comments or in our email. Please advice to build this website even better
Source : Install MySQL 8.0 Debian | Medium