In today’s world, data is KING. No business can survive without good, reliable data. And no data can be good without a good, reliable database. In this tutorial will explain how to install latest database MySQL 8.0 Community Server on Ubuntu and Debian Linux server.

So, what is a database, exactly? A database is a collection of information that can be accessed by computers. It stores information about customers, products, orders, etc.

MySQL is a popular database. It is used by millions of web and business applications. It is free and easy to use. MySQL is a relational database. This means that it stores data in tables. A table is a collection of records. Each record is composed of a column

The MySQL is Dual Licensed. Users can choose to use the MySQL as an Open Source product under the terms of the GNU General Public License (www.gnu.org) or can purchase a standard commercial license from Oracle. See www.mysql.com for more information.

MySQL Database Lifecycle

VersionRelease DateEnd of life
8.008 Apr 201830 Apr 2026
5.709 Oct 201531 Oct 2023
5.601 Feb 201328 Feb 2021
MySQL Database EOL
latest mysql 8.0 installation on Ubuntu and Debian
Latest MySQL 8.0 installation on Debian based server

Steps to install MySQL 8.0 on Ubuntu and Debian Linux server

Installation of MySQL Database 8.0 on Linux is easy. This tutorial will explain how to install MySQL version 8.0 Community Server edition on Ubuntu and Debian based servers.

If you want to install MySQL on RHEL based servers then please read this article.

Prerequisites:

  • sudo privileges.
  • Stable internet connection.
  • Disable SELinux and Firewall

TL;DR

If you want to install default available MySQL version then run following command:

# apt install mysql-community-server -y

Install latest MySQL 8.0 on Ubuntu and Debian server :

Steps to install MySQL 8.0 on Ubuntu and Debian Linux server

Check your current Operating System version if you are not sure:

# egrep '^(VERSION|NAME)=' /etc/os-release

Install the prerequisites:

# apt install -y curl wget gnupg2

We need to add GPG key for MySQL repo:

# apt-key adv --keyserver pgp.mit.edu --recv-keys 467B942D3A79BD29

Now set up the apt repository as per your Ubuntu version:

For Ubuntu 22.04 (Jammy)
# echo "deb https://repo.mysql.com/apt/ubuntu/ jammy mysql-apt-config
deb https://repo.mysql.com/apt/ubuntu/ jammy mysql-8.0
deb https://repo.mysql.com/apt/ubuntu/ jammy mysql-tools
deb https://repo.mysql.com/apt/ubuntu/ jammy mysql-cluster-8.0
deb-src https://repo.mysql.com/apt/ubuntu/ jammy mysql-8.0" | sudo tee /etc/apt/sources.list.d/mysql-8.0.list

For Ubuntu 20.04 (Focal):
# echo "deb https://repo.mysql.com/apt/ubuntu/ focal mysql-apt-config
deb https://repo.mysql.com/apt/ubuntu/ focal mysql-8.0
deb https://repo.mysql.com/apt/ubuntu/ focal mysql-tools
deb https://repo.mysql.com/apt/ubuntu/ focal mysql-cluster-8.0
deb-src https://repo.mysql.com/apt/ubuntu/ focal mysql-8.0" | sudo tee /etc/apt/sources.list.d/mysql-8.0.list

For Ubuntu 18.04 (Bionic):
# echo "deb https://repo.mysql.com/apt/ubuntu/ bionic mysql-apt-config
deb https://repo.mysql.com/apt/ubuntu/ bionic mysql-8.0
deb https://repo.mysql.com/apt/ubuntu/ bionic mysql-tools
deb https://repo.mysql.com/apt/ubuntu/ bionic mysql-cluster-8.0
deb-src https://repo.mysql.com/apt/ubuntu/ bionic mysql-8.0" | sudo tee /etc/apt/sources.list.d/mysql-8.0.list

For Ubuntu 16.04 (Xenial):
# echo "deb https://repo.mysql.com/apt/ubuntu/ xenial mysql-apt-config
deb https://repo.mysql.com/apt/ubuntu/ xenial mysql-8.0
deb https://repo.mysql.com/apt/ubuntu/ xenial mysql-tools
deb https://repo.mysql.com/apt/ubuntu/ xenial mysql-cluster-8.0
deb-src https://repo.mysql.com/apt/ubuntu/ xenial mysql-8.0" | sudo tee /etc/apt/sources.list.d/mysql-8.0.list

Or set up the apt repository as per your Debian version:

For Debian 11 "bullseye"
# echo "deb https://repo.mysql.com/apt/debian/ bullseye mysql-apt-config
deb https://repo.mysql.com/apt/debian/ bullseye mysql-8.0
deb https://repo.mysql.com/apt/debian/ bullseye mysql-tools
deb https://repo.mysql.com/apt/debian/ bullseye mysql-cluster-8.0
deb-src https://repo.mysql.com/apt/debian/ bullseye mysql-8.0" | sudo tee /etc/apt/sources.list.d/mysql-8.0.list

For Debian 10 "Buster"
# echo "deb https://repo.mysql.com/apt/debian/ buster mysql-apt-config
deb https://repo.mysql.com/apt/debian/ buster mysql-8.0
deb https://repo.mysql.com/apt/debian/ buster mysql-tools
deb https://repo.mysql.com/apt/debian/ buster mysql-cluster-8.0
deb-src https://repo.mysql.com/apt/debian/ buster mysql-8.0" | sudo tee /etc/apt/sources.list.d/mysql-8.0.list

For Debian 9 "Stretch"
# echo "deb https://repo.mysql.com/apt/debian/ stretch mysql-apt-config
deb https://repo.mysql.com/apt/debian/ stretch mysql-8.0
deb https://repo.mysql.com/apt/debian/ stretch mysql-tools
deb https://repo.mysql.com/apt/debian/ stretch mysql-cluster-8.0
deb-src https://repo.mysql.com/apt/debian/ stretch mysql-8.0" | sudo tee /etc/apt/sources.list.d/mysql-8.0.list

For Debian 8 "Jessie"
# echo "deb https://repo.mysql.com/apt/debian/ jessie mysql-apt-config
deb https://repo.mysql.com/apt/debian/jessie mysql-8.0
deb https://repo.mysql.com/apt/debian/ jessie mysql-tools
deb-src https://repo.mysql.com/apt/debian/ jessie mysql-8.0" | sudo tee /etc/apt/sources.list.d/mysql-8.0.list

Then update the local package database:

#  apt update

Then Install the MySQL 8.0 latest version:

# apt install -y mysql-community-server

In installation process MySQL will ask for root password, so set complex password for security purpose and most important save password to safe place before preceding. Then select strong password Encryption method to complete the setup.

 Managing the MySQL service

let’s review some basic management commands.

Verify installed version of MySQL:

#  mysql --version

Start the MySQL service:

# systemctl start mysql.service

Check status of the MySQL service:

# systemctl status mysql.service

Restart the MySQL service:

# systemctl restart mysql.service

If you want to stop MySQL service:

# systemctl stop mysql.service

By default, MySQL service is disabled to start automatically when the server boots. If you want to enable it at startup, run:

# systemctl enable mysql.service

Re-disable the service to start up at boot:

# systemctl disable mysql.service

Uninstall MySQL

To completely remove MySQL from a system, you must remove the MySQL applications, the configuration files, and any directories containing data and logs.

WARNING: This process will completely remove MySQL, its configuration, and all databases. This process is not reversible, so ensure that all of your configuration and data is backed up before proceeding.

Stop the MySQL service

# systemctl stop mysql.service

Remove any MySQL packages that previously installed.

# apt autoremove --purge mysql*

Remove MySQL databases and log files.

# rm -rf /var/lib/mysql /var/log/mysql /etc/mysql /var/run/mysqld /etc/apparmor.d/abstractions/mysql

Conclusion

Congratulations! We’ve installed latest MySQL 8.0 on Ubuntu and Debian Linux servers. We hope this 2 minutes stuff helped you and thank you for visiting our website.
Cheers!!!