The “MySQL” is an open-source “RDBMS” or Relational Database Management System. It is currently in use for storing the data inside the tables. Most developers use it to store data from their websites because of its speed, security, and reliability features. You can secure it using a password. “MySQL” is not officially available for Debian 12, but you can install it without any difficulty.

Today’s post sheds light on the steps to “Install the MySQL on Debian 12 Bookworm”.

Quick Outline:

Let’s begin!

How to Install MySQL on Debian 12 Bookworm

The complete process to install “MySQL” on Debian 12 is illustrated in the steps below:

  • Step 1: Update the System’s Packages.
  • Step 2: Add MySQL Repository to Your System.
  • Step 3: Install and Configure MySQL on Debian 12.
  • Step 4: Start MySQL Service.
  • Step 5: Secure MySQL Server.
  • Step 6: Install libmysqlclient21 (Optional).

Let’s explain and illustrate the above steps:

Step 1: Update the System Packages

Before installing “MySQL” server, update the system’s packages using:

sudo apt update

Step 2: Add MySQL Repository to Your System

Next, add the “MySQL” repository by executing the following command. By adding this repository, you can install “MySQL” on your system as it is not available in the official sources:

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

Step 3: Install and Configure MySQL on Debian 12

Now, you can install “MySQL Configuration Files” for adding the “MySQL APT Repository” using the below command. After installing it, select the “debian bullseye” option since it does not support Debian 12 Bookworm:

sudo dpkg -i ./mysql-apt-config_0.8.25-1_all.deb

Now, select the option “mysql-8.0” or the latest version specified from the following screen:

Note: Via the above screen, you can install the “mysql-cluster-8.0”, which is a highly scalable and high availability MYSQL solution. 

Next, select the MYSQL product to install (MySQL Serve & Cluster in this case):

Note: Some users may not see the above window, to pop it up, run the following command:

sudo dpkg-reconfigure mysql-apt-config

Finally, install “MySQL on Debian 12” by executing the below-mentioned command:

sudo apt install mysql-server

After installing it, the wizard asks the user to set up a root password. Hit the Enter button after specifying the password:

After that, select the encryption method. Here the “Use a Strong Password” is recommended as it secures your databases with strong encryption methods:

To verify the installation of “MySQL” and see its version, run:

mysql -V

Step 4: Start and Enable MySQL Service

After completing the installation of “MySQL”, start its service using the following command:

sudo systemctl start mysql

Now, check the service status via the below command:

sudo systemctl status mysql

To automatically start “MySQL” service at the system boot, execute the following command:

sudo systemctl enable mysql

Step 5: Secure MySQL Server 

To secure “MySQL Server” run the below command and the wizard asks to “setup VALIDATE PASSWORD” component, use the “Y” to continue. Now, select a number following which, the users must add their passwords:

sudo mysql_secure_installation

Step 6: Install libmysqlclient21 (Optional)

The “libmysqlclient21” is a client-side library that allows MYSQL to connect with the applications written in the C and C++ languages. To install it, run the following command:

sudo apt install libmysqlclient21

Bonus Tip: Uninstall/Remove MySQL From Debian 12

To uninstall/remove “MySQL” from Debian 12, run the below command to remove its configuration files first:

sudo apt purge mysql-server

After removing the configuration files of “MySQL”, use the following command to completely remove it:

sudo apt autoremove

How to Use MySQL on Debian 12 Bookworm?

After setting up “MySQL”, use the following command to log in and enter the password you have set for the root user:

sudo mysql -u root -p

That’s all for installing “MySQL on Debian 12 Bookworm”.

Final Words

The “MySQL Server” is a world-famous RDBMS that stores the data in the form of tables. It is not officially available on Debian 12, but using the repositories, users can install it with ease. The complete process to “Install MySQL on Debian 12” is discussed above. 

This guide has shed light on the steps to install “MySQL on Debian 12”.