MySQL: Package 'mysql-server' has no installation candidate
Resolving 'mysql-server' No Installation Candidate Error on Debian/Ubuntu

Encountering 'Package 'mysql-server' has no installation candidate' is a common issue on Debian/Ubuntu. This guide explains the root causes and provides comprehensive solutions to successfully install MySQL.
When attempting to install MySQL on a Debian or Ubuntu-based system, you might encounter the error message: Package 'mysql-server' has no installation candidate
. This typically means that your system's package manager (APT) cannot find the mysql-server
package in its configured repositories. This article will walk you through the common reasons for this error and provide step-by-step solutions to get MySQL installed correctly on your system.
Understanding the 'No Installation Candidate' Error
The no installation candidate
error indicates that apt
(Advanced Package Tool) cannot locate a suitable package version in any of the sources listed in your /etc/apt/sources.list
file or files within /etc/apt/sources.list.d/
. This can happen for several reasons, including outdated package lists, incorrect repository configurations, or the package simply not being available for your specific distribution version.
flowchart TD A[User attempts 'sudo apt install mysql-server'] --> B{APT checks local package cache} B --> C{Cache outdated?} C -- Yes --> D[Run 'sudo apt update'] C -- No --> E{APT checks configured repositories} E --> F{Repository missing/incorrect?} F -- Yes --> G[Add/Correct repository] F -- No --> H{Package name incorrect/unavailable?} H -- Yes --> I[Verify package name/distribution compatibility] H -- No --> J[Installation successful]
Flowchart illustrating the troubleshooting process for 'no installation candidate' error.
Common Causes and Solutions
Let's explore the most frequent causes for this error and their respective solutions. Addressing these systematically will help you resolve the issue efficiently.
sudo apt update
before attempting any package installation or troubleshooting. This refreshes your local package index with the latest information from the repositories.1. Outdated Package Lists
The most common reason for this error is an outdated local package index. Your system's apt
cache needs to be refreshed to know about the latest available packages and their versions from the configured repositories.
sudo apt update
sudo apt install mysql-server
Update package lists and then attempt installation.
2. Missing or Incorrect Repositories
Sometimes, the necessary repositories that host the mysql-server
package might not be enabled or correctly configured on your system. For Ubuntu, the universe
repository often contains many open-source packages, including MySQL. For Debian, ensure you have main
, contrib
, and non-free
(if needed) enabled.
# For Ubuntu, enable the 'universe' repository
sudo add-apt-repository universe
sudo apt update
sudo apt install mysql-server
# For Debian, ensure your /etc/apt/sources.list includes 'main contrib non-free'
# Example line for Debian 11 (Bullseye):
# deb http://deb.debian.org/debian/ bullseye main contrib non-free
# deb http://deb.debian.org/debian/ bullseye-updates main contrib non-free
# deb http://security.debian.org/debian-security bullseye-security main contrib non-free
Enabling the 'universe' repository on Ubuntu or verifying Debian sources.list.
3. Specific MySQL Version or Official MySQL APT Repository
If you need a specific version of MySQL not available in your distribution's default repositories, or if you prefer to use the official MySQL APT repository for the latest versions and features, you'll need to add it manually. This involves downloading and installing the MySQL APT repository configuration package.
1. Download MySQL APT Repository Package
Visit the official MySQL APT repository download page (dev.mysql.com/downloads/repo/apt/) and download the .deb
package for your distribution. Alternatively, use wget
:
2. Install the Repository Package
Install the downloaded .deb
package. This will add the MySQL APT repository to your system's sources and configure it.
3. Update APT Cache
After adding the new repository, update your package lists so apt
recognizes the new packages.
4. Install MySQL Server
Now you can install the mysql-server
package. During installation, you might be prompted to configure the MySQL root password and choose an authentication method.
# Step 1: Download the MySQL APT repository package (example for Ubuntu 22.04)
wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb
# Step 2: Install the repository package
sudo dpkg -i mysql-apt-config_0.8.22-1_all.deb
# Follow the prompts to select the MySQL version you want to install.
# Step 3: Update APT cache
sudo apt update
# Step 4: Install MySQL Server
sudo apt install mysql-server
Adding the official MySQL APT repository and installing MySQL.
4. Package Name Discrepancies (MariaDB vs. MySQL)
On some systems, especially newer Debian/Ubuntu versions, MariaDB has replaced MySQL as the default relational database. If you specifically need Oracle MySQL and are getting this error, it might be due to the system preferring MariaDB. Ensure you are explicitly trying to install mysql-server
after adding the correct repositories.
If you intended to install MariaDB, the package name is typically mariadb-server
.
sudo apt install mariadb-server
Installing MariaDB server instead of MySQL.