How to Install MySQL on Debian 12 (Bookworm)

MySQL is a popular free and open-source RDBMS (Relational Database Management System) used to store data in the form of tables. Most developers used the MySQL database to store data for online applications, content management systems, and e-commerce websites.

In this tutorial, we will go through the installation of the MySQL Server on the Debian 12 Bookworm distribution.


  • The Debian 12 distribution should be running on your system or VirtualBox.
  • You should have sudo access or root privileges.

MySQL installation on Debian 12

To install MySQL Server on Debian 12 distribution, perform the following steps:

Step 1: Update Repositories Packages

First, open the terminal windows using application search bar:

update all available packages using these commands:

$ sudo apt update

$ sudo apt upgrade

Step 2: Install Required Packages

If you are using a fresh Debian 12 distro, you will install the ‘wget’ package to download apt MySQL repository. Install the wget package using this command:

$ sudo apt install wget

Step 3: Download and add MySQL Apt Repository

MySQL is not available in the Debian 12 repository. However, you can download and add an apt MySQL repository to your Debian system. So, download the recent MySQL release from the official MySQL download page using this command:

$ wget

Now, add this package to your system using the below-mentioned command:

$ sudo apt install ./mysql-apt-config_0.8.25-1_all.deb

Step 4: Install MySQL on Debian 12

Once the MySQL package is added to your system, you can install MySQL on the Debian system. Update the system repositories and use the below command to install the MySQL server on Debian 12:

$ sudo apt update
$ sudo apt install mysql-server

After running the above command, you are required to enter the password for root to use MySQL database login.

Enter the password and re-enter again to confirm this password.

Select ‘ok’ and the below output will display on the terminal:

Now, check the installed MySQL version:

$ mysql --version

Step 5: Start MySQL Service

Once the MySQL installation is complete, the MySQL service will automatically start and run on your system. You can also check whether MySQL service is running on your system or not using this command:

$ sudo systemctl status mysql

If you want to stop the MySQL service due to any reason, you can stop Mysql service using this command:

$ sudo systemctl stop mysql

To start MySQL again, use this command to start MySQL service on Debian 12:

$ sudo systemctl start mysql

Step 6: Access MySQL Database

To access MySQL databases, log in to the MySQL server as root using this command:

$ mysql -u root -p

Enter the password that you enter as the root password during the MySQL installation. After that, the following MySQL shell will open on the terminal:

Type the ‘exit’ command to leave the MySQL shell:

> exit

Uninstall MySQL from Debian 12

To uninstall MySQL from Debian 12, stop MySQL and use this command:

$ sudo apt purge MySQL-server


We learned how to install MySQL server on Debian 12 Bookworm distribution. MySQL database can be used for both small and large applications. Different versions are available that you can download based on your use case.


Print Friendly, PDF & Email


Add yours
  1. 1

    Thank you for this article, really helpful!
    But I have a problem when I running ‘apt-update’

    l# apt update
    Hit:1 bookworm-security InRelease
    Hit:2 bookworm InRelease
    Hit:3 bookworm-updates InRelease
    Ign:4 bookworm InRelease
    Err:5 bookworm Release
    404 Not Found [IP: x.y.z.x 8080]
    Reading package lists… Done
    E: The repository ‘ bookworm Release’ does not have a Release file.
    N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
    N: See apt-secure(8) manpage for repository creation and user configuration details.

    So, how did you solve this kind of problem?
    The distribution file doesn’t contains bookworm yet…

  2. 2

    Maybe you have to select the ubuntu kinetic repo, because debian bookworm repo, doesn`t exist yet

Comments are closed.