Wednesday, October 9, 2024
Google search engine
HomeData Modelling & AIHow To Install MySQL 8.0 on Debian 11/10 /9

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

This tutorial has been written to help you install MySQL 8 on Debian 11 / Debian 10 / Debian 9. This guide is for a fresh installation of MySQL 8.0 on Debian 11/10/9 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:

Follow steps below to Install MySQL 8.0 on Debian 11/10/9 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://repo.mysql.com//mysql-apt-config_0.8.22-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.22-1_all.deb

Agree to configure MySQL Apt repository.

install mysql 8.0 debian 9 debian 8 01

Confirm addition of MySQL 8.0 repository as default when prompted.

install mysql 8.0 debian 9 debian 8 02

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

Step 2: Install MySQL 8.0 on Debian 11/10/9

Once the repository has been added, install MySQL 8.0 on Debian 11/10/9 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 11/10 /9.

install mysql 8.0 debian 9 debian 8 05

Check version installed using the apt-policycommand:

$ apt policy mysql-server
mysql-server:
  Installed: (none)
  Candidate: 8.0.29-1debian11
  Version table:
     8.0.29-1debian11 500
        500 http://repo.mysql.com/apt/debian bullseye/mysql-8.0 amd64 Packages

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; vendor preset: enabled)
     Active: active (running) since Sun 2021-08-22 00:29:53 UTC; 43s ago
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 26431 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 26590 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 2340)
     Memory: 358.2M
        CPU: 1.831s
     CGroup: /system.slice/mysql.service
             └─26590 /usr/sbin/mysqld

Aug 22 00:29:43 debian-bullseye-01 systemd[1]: Starting MySQL Community Server...
Aug 22 00:29:43 debian-bullseye-01 su[26466]: (to mysql) root on none
Aug 22 00:29:43 debian-bullseye-01 su[26466]: pam_unix(su-l:session): session opened for user mysql(uid=108) by (uid=0)
Aug 22 00:29:53 debian-bullseye-01 systemd[1]: Started MySQL Community Server.

Step 3: Test MySQL 8.0 Installation on Debian 11/10/9

Let’s test to confirm if MySQL 8.0 installed on Debian 11/10 /9 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.
Your MySQL connection id is 9
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> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.26    |
+-----------+
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
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
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> 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

Install Desktop Database Management Tool

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

Install and Configure DBeaver on Fedora & CentOS

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.

Best Udemy Video Courses to Learn MySQL / MariaDB Databases:

RELATED ARTICLES

Most Popular

Recent Comments