How to Install MySQL on Debian 12 Step-by-Step

The step-by-step guide on this page will explain you how to install MySQL on Debian 12.

MySQL is a free and open-source relational database management system (RDBMS) for storing data in table format. It comes with two editions: Community Server (open source) and Enterprise Server (proprietary).

The source code for both editions is identical; however, the proprietary edition has a number of additional files that can be added as server plugins. Most developers utilized MySQL databases to hold data for e-commerce websites, content management systems, and online apps.

[ez-toc]

Prerequisites

  • Pre-Install Debian 12 System
  • Root or sudo privileges
  • Internet Connectivity

Step 1: Update the Repositories Packages

Run the following command:

$ sudo apt update

Step 2: Add MySQL APT Repository

To download the MySQL server, install the wget package first if you run a freshly installed Debian distribution. Use the following command to install the wget package:

$ sudo apt install wget -y

Now use wget command to download the most recent version of MySQL APT repository Debian file from the official MySQL download page.

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

MySQL-APT-Config-Debian-Linux

Proceed to add the deb package to your repositories by using the command as shown:

$ sudo apt install ./mysql-apt-config_*_all.deb

A pop-up window displays after you run the above command. Select MySQL Server & Cluster with the Arrow key and hit Enter.

Configure-MySQL-APT-Repository-Debian12

In this instance, MySQL-8.0 is the version of the server that was available. Select MySQL-8.0 and click  Enter.

Choose-MySQL-8-Server-Version-Debian

Now, click OK on your screen to finish the configuration.

Choose-OK-to-Finish-MySQL-APT-Repository-Configuration

Note: Going forward, if you want to modify MySQL configuration or add extra tools via its repository, use the command as shown:

$ sudo dpkg-reconfigure mysql-apt-config

Step 3: Install MySQL on Debian 12

In order for the system to identify the packages that are available on your recently uploaded repository, run the system update command to refresh the cache data.

$ sudo apt update

Now, install the MySQL deb package by utilizing the following command.

$ sudo apt install mysql-server

Install-MySQL-on-Debian12-Apt-Command

In this pop display, enter the root password in order to configure mysql server.

Set-MySQL-Server-Root-Password-Debian

To confirm the root password, re-enter it again

Confirm-MySQL-Root-Password-Debian

In this window, select Use Strong Password Encryption and click OK to finish the installation of MySQL 8.0 on Debian 12.

Authentication-Plugin-MySQL-Server-Debian-Linux

Step 5: Start and Enable the MySQL Server

Let’s launch and enable the Oracle MySQL service on Debian after the installation is finished so that it can start automatically when the system boots.

$ sudo systemctl enable --now mysql

To check if the MySQL service is up and running, execute the command shown:

$ sudo systemctl status mysql

MySQL-Service-Status-Debian

Extra info: To check the MySQL version installed, run the command as shown:

$ mysql --version

Check-MySQL-Server-Version-Debian

Step 6: How to Secure the MySQL Database Server

This extra step ensures that we take all required precautions to ensure that our database is sufficiently secure to thwart any malevolent effort by someone to access it.

$ sudo mysql_secure_installation

Setting up the VALIDATE PASSWORD PLUGIN, which checks the strength of MySQL passwords, will be configured at this point. Press y to continue with the process.

After that, you will be given the option to choose from three different password strength levels: weak, medium, and strong. Enter 2 to select the strong password validation policy.

Next, create a password for the root MySQL user and double-check it.

You’ll then be prompted to reload the privilege tables, remove the anonymous user, restrict access to the local computer for the root user, and erase the test database. We suggest responding to every query with a y flag.

Secure-MySQL-Server-Debain

Step 7: Login to Your MySQL Server

Now let’s log in as root in order to access our database server. Next, run the following command and enter the password.

$ mysql -u root -p

Login-MySQL-Server-Command-Linux-Debian

You can use the following command to see the current state of your MySQL:

STATUS;

Check-MySQL-Status-Command-Line-Linux

Wrapping up

MySQL 8.0 has been proven to be installed and operational on Debian 12. We appreciate you utilizing our tutorial, and we hope you will return soon for more database administration-related information.

Also Read: How to Install and Use Timeshift on Debian 12

Leave a Comment

four × 5 =