In this guide, you will learn to Install MySQL LTS on Debian 12 Bookworm. MySQL is a Relational Database Management System (RDBMS). It is available in two editions:
- MySQL Community Server (Open Source).
- MySQL Enterprise Server (Proprietary).
Both of the editions share the same code base except, Enterprise Edition comes with a series of extensions that can be installed as server plugins.
Now follow the steps below to complete your MySQL installation on Debian 12.
Complete Guide To Install MySQL LTS on Debian 12 Bookworm
To complete this guide, you must have access to your server as a non-root user with sudo privileges. To do this, you can follow this guide on Initial Server Setup with Debian 12 Bookworm.
Step 1 – Download and Install MySQL Deb Package
sudo wget https://dev.mysql.com/get/mysql-apt-config_0.8.25-1_all.deb
Then, you need to install the package with the following command:
sudo apt install ./mysql-apt-config_*_all.deb
Fix Error Debian Bookworm is not supported by MySQL
You will get the message that, Debian Bookworm is not supported by MySQL. So to install MySQL, we use the Debian bullseye repository. Select it and click OK.
Next, you need to select MySQL Server & Cluster, then press the TAB button to select OK and hit the Enter key.
Next, you need to choose the available version of MySQL on Debian 12, here in our case it was MySQL 8.0.
Again Select OK and then use the TAB to move to OK and hit the Enter key.
This will automatically configure the latest Debian repository of the Database on your Debian 12.
Note: If you see an error like the following during the installation:
Download is performed unsandboxed as root as file '/root/mysql-apt-config_0.8.25-1_all.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
Usually apt uses the user _apt to download packages. In this case, _apt doesn’t have to write permission and download the file as root. To resolve it, you need to make sure the package is writeable for user _apt:
sudo chown -Rv _apt:root /root/mysql-apt-config_0.8.25-1_all.deb
sudo chmod -Rv 700 /root/mysql-apt-config_0.8.25-1_all.deb
By running these commands, the error must be solved. To get more information, you can visit this guide on Fix APT Error Download is performed unsandboxed as root.
Note: If you want to add any additional tools using its repository or want to reconfigure it run the command below:
sudo dpkg-reconfigure mysql-apt-config
Step 2 – Install MySQL Server on Debian 12
Update your local package index with the following command:
sudo apt update
Then, install MySQL on Debian 12 with the following command:
sudo apt install mysql-server
You need to enter the password that you want to use with the MySQL server.
Then select the Strong authentication method.
Now proceed to the next step to start and enable your MySQL service on Debian 12.
Step 3 – Manage MySQL Service on Debian 12
At this point, you can start and enable your MySQL service on Debian 12 with the command below:
sudo systemctl enable --now mysql
To see your MySQL version, you can run the command below:
mysql Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)
Step 4 – Secure MySQL installation on Debian 12
At this point, you secure your MySQL by running the MySQL secure script:
You will be asked to enter the root password. Also, you will be asked to set a valid password component. And you will be asked if you want to change your root password. Answer them as you wish from there type y to continue.
Then, you can log in to your MySQL shell by using the command below:
sudo mysql -u root -p
At this point, you have learned to Install MySQL on Debian 12 Bookworm by using an unsupported repository, because MySQL doesn’t support Debian Bookworm at the current time. You learned to run the security script to set a password for your MySQL and increase your MySQL security.
Also, you may find out the basic usage of MySQL by visiting this guide on Basic MySQL in Linux.