How To Install MySQL 8.0 / 5.7 on Debian 11 / Debian 10

0

MySQL is one of the most widely used relational database management systems in the world. It is free software licensed under the GPL (General Public License).

A Swedish company, MySQL AB, originally developed MySQL. Now it is owned and developed by the Oracle Corporation.

In this article, we will see how to Install MySQL on Debian 11 / Debian 10.

Add MySQL Repository

MySQL server packages are available through its official repository.  So, we will now download and install the MySQL repository setup package.

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

Install the repository package using the dpkg command.

sudo dpkg -i mysql-apt-config_0.8.18-1_all.deb
At the time of writing this post, MySQL 8.0 repository is not yet available for Debian 11 (Bullseye). However, we can use Debian 10 (Buster) MySQL repository to get MySQL 8.0 packages for Debian 11.

For Debian 11: Choose the Debian buster and then press Enter.

The package installer will prompt you to select the MySQL version for creating the repository. Go to MySQL 8.0 or MySQL 5.7 section to know more about selecting the right repository for your MySQL installation.

Install MySQL Community Server

Install MySQL Server 8.0

By default, MySQL version 8.0 is selected for the configuration of the repository.

Use the down arrow to choose OK and then press Enter

Wait for the repository configuration to complete and then update the repository index using the apt command.

sudo apt update

Run the following command to install MySQL server 8.0.

sudo apt install -y mysql-community-server

The package installer will prompt you to,

1. Enter MySQL root password

2. Re-Enter MySQL root password

3. Choose Authentication Method

Use Strong Password Encryption: MySQL will use a new authentication based on the SHA256 password methods. If you choose this method, only the latest version of clients and connectors with caching_sha2_password support can connect to the MySQL server

Use Legacy Authentication Method (Recommended for phpMyAdmin): MySQL will use the old authentication method (mysql_native_password) which all clients and connectors support.

Install MySQL Server 5.7

By default, MySQL version 8.0 is selected for the repository configuration. So, we need to change it to MySQL 5.7 by following the below steps to set up MySQL 5.7 repository.

1. Ensure your selection is in MySQL Server & Cluster (Currently selected: mysql-8.0)  and press Enter

2. Choose mysql-5.7 and then press Enter

3. Now, you should see MySQL Server & Cluster (Currently selected: mysql-5.7)

4. Use the down arrow to choose OK and then press Enter

Update the repository index using the apt update command.

sudo apt update

Use the apt command to MySQL server 5.7.

sudo apt install -y mysql-community-server

The package installer will prompt you to,

1. Enter MySQL root password

2. Re-Enter MySQL root password

Check MySQL Server

After the installation of the MySQL server, run the following command to check the status MySQL server.

sudo systemctl status mysql

Output:

 mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2021-08-23 05:38:59 CDT; 1min 52s ago
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 2563 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 2598 (mysqld)
     Status: "Server is operational"
      Tasks: 37 (limit: 2321)
     Memory: 359.5M
        CPU: 1.037s
     CGroup: /system.slice/mysql.service
             └─2598 /usr/sbin/mysqld

Aug 23 05:38:58 debian11.itzgeek.local systemd[1]: Starting MySQL Community Server...
Aug 23 05:38:59 debian11.itzgeek.local systemd[1]: Started MySQL Community Server.

Work with MySQL Server

Login to MySQL with the MySQL root user and the password you had set during the installation.

mysql -u root -p

Output

MySQL 5.7:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.35 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>

MySQL 8.0:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26 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>

Install phpMyAdmin

PHPMyAdmin is a tool written in PHP intended to handle the administration of MySQL and MariaDB servers over the web browser. It provides you with an interface for administrative operations on your database: create, drop, alter tables, delete.

READ: How To Install phpMyAdmin With Apache on Debian 11 / Debian 10

Conclusion

That’s All. I hope you have learned how to Install MySQL on Debian 11 / Debian 10.

You might also like