How To Install MySQL 8.0 on Debian 10 “Buster”

DigitalOcean Referral Badge
Start your VPS now with FREE $100 credit.

On today’s guide we will guide you on how to install and configure MySQL 8.0 on Debian 10 “Buster”. MySQL 8.0 is the current latest stable release of MySQL database server, one of the most used, popular, free open-source database server (FOSS) on the world. We will install MySQL 8.0 using the MySQL APT Repository which is available on MySQL website. It will provides deb packages for installing and managing MySQL server along with its MySQL client, and other components for Debian 10 codename Buster.

There are several features which have been added into the MySQL 8.0 database server like Data dictionary, Atomic data definition statements (Atomic DDL), Upgrade procedure, Session Reuse, Security and account management, Resource management, Table encryption management, as well as InnoDB enhancements.

Starting from MySQL 8.0, there is a data dictionary which incorporates a transactional data dictionary and it stores information about database objects. Where in the previous MySQL version, data dictionary was stored in metadata files and non-transactional tables. While the Atomic DDL statement combines some values like data dictionary updates, storage engine operations, and binary log writes associated with a DDL operation into a single atomic transaction.

Before going to the MySQL 8.0 installation proccedure, make sure to meet the following requirenments.

PREREQUISITES:

* VPS, Cloud, Bare Metal or Physical Servers
* Running under distro Debian 10 "Buster"
* Superuser Privileges or Root Access
* Must Be Familiar with Linux Command Line (CLI-Based Only)
* gNome Terminal for Linux Desktop
* PuTTy SSH Client for Windows and MacOS
* PowerShell for Windows 10/11

1.) Add MySQL APT Repository

On the first step you need to add the MySQL APT Repository into your Debian 10 machine. Kindly run the following command to add and download the MySQL 8.0 APT Repository into your machine using wget command.

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

--2022-06-18 17:22:47-- https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://repo.mysql.com//mysql-apt-config_0.8.22-1_all.deb [following]
--2022-06-18 17:22:48-- https://repo.mysql.com//mysql-apt-config_0.8.22-1_all.deb
Resolving repo.mysql.com (repo.mysql.com)... 184.50.240.231
Connecting to repo.mysql.com (repo.mysql.com)|184.50.240.231|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18012 (18K) [application/x-debian-package]
Saving to: ‘mysql-apt-config_0.8.22-1_all.deb’

mysql-apt-config_0.8.22-1_all.deb 100%[======================================================================>] 17.59K --.-KB/s in 0s

2022-06-18 17:22:48 (149 MB/s) - ‘mysql-apt-config_0.8.22-1_all.deb’ saved [18012/18012]

OR

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

--2022-06-19 03:16:13-- https://repo.mysql.com/mysql-apt-config_0.8.22-1_all.deb
Resolving repo.mysql.com (repo.mysql.com)... 184.50.240.231
Connecting to repo.mysql.com (repo.mysql.com)|184.50.240.231|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18012 (18K) [application/x-debian-package]
Saving to: ‘mysql-apt-config_0.8.22-1_all.deb’

mysql-apt-config_0.8.22-1_all.deb 100%[======================================================================>] 17.59K --.-KB/s in 0.02s

2022-06-19 03:16:13 (1017 KB/s) - ‘mysql-apt-config_0.8.22-1_all.deb’ saved [18012/18012]

You can also go to the MySQL download page to see the MySQL APT Repository at the following URL:

> https://dev.mysql.com/downloads/repo/apt/

2.) Install the Downloaded Release Package of MySQL 8.0

After that you can select and download the release package of MySQL 8.0 for your Debian 10 machine. It actually the same package which will works on all supported Debian and Ubuntu LTS server. Simply run the following command, and don’t forget to replace “version-specific-package-name” with the actual name of the downloaded package release.

$ sudo dpkg -i /PATH/version-specific-package-name.deb

On this case as follow:

$ sudo dpkg -i mysql-apt-config_0.8.22-1_all.deb

Selecting previously unselected package mysql-apt-config.
(Reading database ... 34258 files and directories currently installed.)
Preparing to unpack mysql-apt-config_0.8.22-1_all.deb ...
Unpacking mysql-apt-config (0.8.22-1) ...
Setting up mysql-apt-config (0.8.22-1) ...
Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config)
OK

During the installation progress, on the prompt screen you will be asked to choose the MySQL versions which you want to use on your Debian 10 machine along with other components like MySQL Cluster and MySL Workbench. However, simply enable MySQL 8.0 since we will install and use this version on your Debian stable machine.

READ:  How To Create Database, User and Password on MySQL 8.0.26 via Command Line Interface (CLI)

3.) Run System Update

Then simply run system update to get the latest stable available package releases both from your OS vendor and MySQL APT Repository. Please note that once the MySQL APT repository is enabled on your machine, you cannot install any MySQL packages from your Debian native software repositories until you have disabled the MySQL APT Repository for your Debian 10 “Buster”.

$ sudo apt-get update

4.) Let’s Install MySQL 8.0

Finally run this command to install MySQL 8.0 database server on your Debian 10 machine along with the packages for the MySQL client and database common files. You need to setup and input MySQL root administrative password during the installation progress of your MySQL 8.0.

$ sudo apt-get install mysql-server

5.) Securing and Hardening MySQL Installation

One of the most important step, don’t forget to securing and hardening your MySQL Installation using the following command. Later you need to re-type the “root password” for your MySQL 8.0 during the securing installation progress. So, simply press “NO” if you asked to change the MySQL Root Password.

$ mysql_secure_installation

6.) Command to Manage MySQL Database Server

The following commands are important to you in order to manage your MySQL 8.0 database server on your Debian 10 machine. The MySQL database server will started automatically after installation progress is finished. You can check the MySQL server status using the following command.

READ:  How To Create Database, User and Password on MySQL 8.0.26 via Command Line Interface (CLI)

Check MySQL Server State

$ systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-06-18 17:26:34 UTC; 20s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 26881 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 4915)
Memory: 363.5M
CGroup: /system.slice/mysql.service
└─26881 /usr/sbin/mysqld

Jun 18 17:26:33 ns376183 systemd[1]: Starting MySQL Community Server...
Jun 18 17:26:34 ns376183 systemd[1]: Started MySQL Community Server.

If you use one of the available Debian/Ubuntu-based distribution system with sysmtemd enabled by default, standard systemctl commands (or alternatively, service with the arguments reversed) like start, stop, restart and status will be used by default to manage the service of the MySQL database server. Also please note that MySQL Server service is enabled by default and will start automatically at system reboot.

Enable MySQL to Start Automatically from Boot

$ systemctl enable mysql.service

To Start MySQL Server

$ systemctl start mysql.service

OR

$ service mysql start

To Stop MySQL Server

$ systemctl stop mysql.service

OR

$ service mysql stop

To Restart MySQL Server

$ systemctl restart mysql.service

OR

$ service mysql restart

7.) Check or Verify MySQL Version

You can check and verify which MySQL version installed on your Debian 10 machine using the following command.

$ mysql -V
mysql Ver 8.0.29 for Linux on x86_64 (MySQL Community Server - GPL)

CONCLUSION:

Now you know that installing and configuring MySQL 8.0 database server on Debian 10 “Buster” is quite easy and you can deploy it in another Debian/Ubuntu-based system. Then to run your website apps, either it blogs, portofolio site, corporate website or run your code with MySQL 8.0 server.

Leave a Comment