Guides 11792 Published by

This article offers a concise guide for installing MySQL Community Edition 8 on Debian 11 Bullseye, explaining why the official Oracle repository is preferred over Debian’s default MariaDB package. It walks readers through adding the GPG key and repo package, updating apt, choosing the correct server version during configuration, and installing the server while setting a root password. The following steps verify that the service is running, harden security with mysql_secure_installation, test connectivity, and provide practical troubleshooting tips for common lock or conflict problems. Altogether, it delivers a clear, step‑by‑step recipe that prepares a fresh MySQL instance for production or local development use.



Install MySQL Community on Debian 11 Bullseye in Minutes

You’re probably looking to get a fresh MySQL 8 instance running on your new Bullseye box. Below is the straight‑up recipe—no fluff, just the steps that actually matter.

Why the Oracle Repo Is Needed

Debian’s own repositories ship MariaDB by default and an older, stripped‑down MySQL client. If you pull `mysql-server` straight from apt, you’ll end up with MariaDB or a very old MySQL build that won’t play nicely with modern PHP frameworks. The official Oracle APT repo gives you the current Community Edition (8.x) in one click.

 Add MySQL’s GPG Key
wget https://dev.mysql.com/get/mysql-apt-config_0.8.29-1_all.deb

The `.deb` package contains the key and repo config. Installing it pulls both in one go. If you skip the key, `apt` will refuse to install anything.

Install the Repo Package
sudo dpkg -i mysql-apt-config_0.8.29-1_all.deb

During installation, a tiny prompt asks which MySQL version you want. Pick “MySQL Server 8.0” and press OK. If you miss that, your server will default to MariaDB later on.

Update the Package List
sudo apt update

If this step fails, double‑check the repo entry in `/etc/apt/sources.list.d/mysql.list`. A typo there can break everything.

 Install MySQL Community Server
sudo apt install mysql-server

When prompted, set a root password. If you leave it blank, you’ll have to run `mysql_secure_installation` later anyway. I’ve seen this happen after an accidental “blank” during the first run of the installer—root ends up with no password and you’re forced into the insecure mode.

Verify the Service
sudo systemctl status mysql

The output should show active (running). If it’s failed, look at `journalctl -u mysql` for clues—often a missing library or port conflict from a leftover MariaDB process.

Harden the Installation
sudo mysql_secure_installation

This script walks you through:

* Removing anonymous users
* Disabling root login over network
* Removing test database

Answer “yes” to all for a clean, production‑ready setup. If you’re running a local dev environment and don’t care about remote access yet, feel free to skip the remote root disable step.

 Test Connectivity
mysql -u root -p

Enter the password you set earlier. You should land on the `mysql>` prompt. If it says access denied, double‑check that you typed the password correctly and that the MySQL user hasn’t been locked by a failed attempt.

Quick Troubleshooting
Symptom Likely Cause Fix
`apt install` stalls on “Waiting for lock” Another apt process running Wait or kill the other process
`mysql` fails to start after upgrade Conflicting MariaDB service still listening on 3306 Stop and disable MariaDB (`sudo systemctl stop mariadb; sudo systemctl disable mariadb`) then restart MySQL

I’ve seen this happen after a bad driver update that pushed an incompatible `libssl.so` into `/usr/lib`. In that case, reinstalling the offending package or rolling back to the previous version solved it.

That’s all. You now have a fully functional MySQL Community Edition on Debian 11 Bullseye and a handful of sanity checks to keep it humming.