This tutorial has been written to help you install MySQL 8 on Debian 12/11/10. This guide is for a fresh installation of MySQL 8.0 on Debian on a server that doesn’t have MariaDB or any other version fo MySQL running. If you have an older version of MySQL Server (e.g 5.7), you’ll need to do an in-place upgrade or dump all data, upgrade packages and re-import all database data to MySQL 8.0.

If you’re running Ubuntu server, use below guides instead:

Installing MySQL 8.0 on Debian 12/11/10

Follow steps below to Install MySQL 8.0 on Debian Linux system.

Step 1: Add MySQL Dev apt repository

MySQL 8.0 packages are available on official MySQL Dev apt repository.

sudo apt update && sudo apt -y  install wget
wget https://dev.mysql.com/get/mysql-apt-config_0.8.33-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.33-1_all.deb

Agree to configure MySQL Apt repository. Click enter to choose repository for MySQL 8.0

install mysql 80 03

Confirm addition of MySQL 8.0 repository as default when prompted.

install mysql 80 01

Then tab to <OK>  and press <Enter> key to confirm version installation.

Step 2: Install MySQL 8.0 packages

Once the repository has been added, install MySQL 8.0 on Debian by running the following commands:

sudo apt update && sudo apt install mysql-server

When asked for the rootpassword, provide the password.

install mysql 8.0 debian 9 debian 8 03

Re-enter root database user password.

install mysql 8.0 debian 9 debian 8 04

Select the Authentication plugin and select <OK> to finish installation of MySQL 8.0 on Debian.

Check version installed using the apt-policycommand:

$ apt policy mysql-server
mysql-server:
  Installed: 8.0.40-1debian12
  Candidate: 8.0.40-1debian12
  Version table:
 *** 8.0.40-1debian12 500
        500 http://repo.mysql.com/apt/debian bookworm/mysql-8.0 amd64 Packages
        100 /var/lib/dpkg/status

The mysql service should be started by default, you can confirm service status using the command:

$ systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: active (running) since Sat 2024-12-14 17:30:53 UTC; 16s ago
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
   Main PID: 2089 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 4531)
     Memory: 372.1M
        CPU: 1.506s
     CGroup: /system.slice/mysql.service
             └─2089 /usr/sbin/mysqld

Dec 14 17:30:52 deb12 systemd[1]: Starting mysql.service - MySQL Community Server...
Dec 14 17:30:53 deb12 systemd[1]: Started mysql.service - MySQL Community Server.

Step 3: Test MySQL 8.0 Installation

Let’s test to confirm if MySQL 8.0 installed on Debian is working as expected.

Login as root user with a created password:

$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.40 MySQL Community Server - GPL

Copyright (c) 2000, 2024, 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.40    |
+-----------+
1 row in set (0.00 sec)

Create a Test database and user.

CREATE USER 'test_user'@'localhost' IDENTIFIED BY "Jek1oleiboafei4eeghu";
CREATE DATABASE test_db;
GRANT ALL PRIVILEGES ON test_db.* TO 'test_user'@'localhost';
FLUSH PRIVILEGES;
QUIT

Try to access the database console as test_user:

$ mysql -u test_user -p
...
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test_db            |
+--------------------+
2 rows in set (0.01 sec)

mysql> QUIT

Once confirmed to be able to login and use assigned database, login again as root user and drop both the test database and user.

mysql> DROP DATABASE test_db;
Query OK, 0 rows affected (0.11 sec)

mysql> DROP USER 'test_user'@'localhost';
Query OK, 0 rows affected (0.11 sec)

mysql> SELECT USER FROM mysql.user;
+------------------+
| USER             |
+------------------+
| mysql.infoschema |
| mysql.session    |
| mysql.sys        |
| root             |
+------------------+
4 rows in set (0.00 sec)

mysql> QUIT
Bye

Step 4: Install Database Management Tool (optional)

If working with MySQL command line is not your thing, then consider installing a Database Tool to help you. Check out our guide below:

MySQL 8.0 has been confirmed to be installed and working on Debian 11 / Debian 10 / Debian 9 Linux. Thank you for using our guide and stay connected for more articles related to Database Administration.

Books for Learning MySQL database systems:

LEAVE A REPLY

Please enter your comment!
Please enter your name here