MySQL: Package 'mysql-server' has no installation candidate
Asked Answered
L

9

25

This error is being shown whenever I want to install any software via command line. Even if i try to install softwares which I know are present at the source from where I am downloading.

Below is the full error message i am getting :

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package mysql-server is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'mysql-server' has no installation candidate
Luis answered 28/11, 2013 at 6:18 Comment(0)
M
39

If you have followed all the previous steps successfully and after running sudo apt-get install mysql-server you are getting an error then try this

sudo apt-get install mariadb-server

It worked for me.

Moriah answered 29/6, 2020 at 3:57 Comment(3)
I spent 7 mins reading the previous answer before this and this answer appealed the most to me. Thanks. it works.Estas
This is a different database and it causes problems when it's removed so the actual mysql db can be installed. Don't recommend this.Corticosteroid
What kind of problems are you referring to so that i can also mention it in my answer.Moriah
D
29

I experienced this issue when trying to install MySQL Server on Debian 10.

Here's how I fixed it:

The issue is caused by the MySQL server apt repository not being included in your system's software repository list. In Debian 10 for example, MariaDB, a community fork of the MySQL project, is packaged as the default MySQL variant.

So to fix this first, add the MySQL server apt repository to your system's software repository list. Follow these steps:

Go to the download page for the MySQL APT repository at:

https://dev.mysql.com/downloads/repo/apt/

Select and download the release package for your Linux distribution. You can use:

sudo wget https://the-download-link

In my case it was:

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

Install the downloaded release package with the following command, replacing version-specific-package-name with the name of the downloaded package (preceded by its path, if you are not running the command inside the folder where the package is):

sudo dpkg -i version-specific-package-name.deb

In my case it was:

sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb

Note: dpkg is used to install, remove, and inspect .deb software packages. The -i flag indicates that we’d like to install from the specified file.

During the installation, you’ll be presented with a configuration screen where you can specify which version of MySQL you’d prefer, along with an option to install repositories for other MySQL-related tools. The defaults will add the repository information for the latest stable version of MySQL and nothing else. This is what we want, so use the down arrow to navigate to the Ok menu option and hit ENTER.

You'll also be asked to select a repository to add. Choose 'debian buster' which has the package 'mysql-server' in it. After the adding this repository you can update the repository and use the below command to install MySQL.

sudo apt-get install mysql-server

The package will now finish adding the repository. Refresh your apt package cache to make the new software packages available:

sudo apt update

Note: If you ever need to update the configuration of these repositories, just run sudo dpkg-reconfigure mysql-apt-config, select new options, and then sudo apt-get update to refresh your package cache.

Install MySQL by the following command:

sudo apt-get install mysql-server mysql-client libmysqlclient-dev

Note: This installs the package for the MySQL server, as well as the packages for the client and for the database common files. During the installation, you are asked to supply a password for the root user for your MySQL installation.

The MySQL server is started automatically after installation. You can check the status of the MySQLserver with the following command:

sudo service mysql status

Stop the MySQL server with the following command:

sudo service mysql stop

To restart the MySQL server, use the following command:

sudo service mysql start

MySQL creates a default user called root. You can change the password to any password of your choice by logging in to MySQL console using socket authentication:

sudo mysql -u root

Then run the command below to change the password

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your-preferred-password';

Reference:

A Quick Guide to Using the MySQL APT Repository

How To Install the Latest MySQL on Debian 10

That's all.

I hope this helps

Divest answered 23/9, 2020 at 15:40 Comment(4)
what is the user name and password?Rader
It creates a default user called root. You can change the password to any password of your choice running the command sudo mysql -u root and then this command ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';Divest
If you get error code like: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; use sudo mysql -u root -p the -p is for password, enter your SQL server password there.Magyar
sudo service mysql status is showing mysql: unrecognized serviceTavia
F
9

You can install mysql by

sudo apt install default-mysql-server

--------
sudo service mysql status
● mariadb.service - MariaDB 10.3.31 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2022-02-09 13:19:33 +08; 33s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 18537 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 31 (limit: 4915)
   Memory: 73.1M
   CGroup: /system.slice/mariadb.service
           └─18537 /usr/sbin/mysqld
Forewoman answered 9/2, 2022 at 5:21 Comment(2)
This doesn't install mysql, this installs mariaDB, which is different.Corticosteroid
This advice has caused me soo much trouble. The MariaDB is a real pain to remove, and even when it's removed, there's artifacts left around which creates severe issues with mysql installations.Corticosteroid
T
2

My System also shows the same error. And i have the debian 12.

this command is working for me.

sudo apt install default-mysql-server
Taenia answered 16/12, 2023 at 21:7 Comment(1)
This is a duplicate of most of the earlier answers.Incoming
R
0

Most likely you are running on ubuntu. It is important to run apt-get update first.

Readiness answered 9/2, 2014 at 19:34 Comment(0)
H
0

run: apt install default-mysql-server

which installs MariaDB unfortunately, but still responds to service mysql status

Hindrance answered 27/11, 2021 at 20:10 Comment(1)
This advice has caused me soo much trouble. The MariaDB is a real pain to remove, and even when it's removed, there's artifacts left around which creates severe issues with mysql installations.Corticosteroid
G
0

The following error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package mysql-server is not available, but is referred to by another package.

may mean that the package is missing, has been obsoleted, or is only available from another source. E: Package 'mysql-server' has no installation candidate

SOLUTION

->sudo apt update

->sudo apt upgrade

->sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*

->sudo rm -rf /etc/mysql /var/lib/mysql

-> sudo apt-get autoremove

-> sudo apt-get autoclean

-> systemctl restart mariadb

-> sudo apt install mariadb-server mariadb-client

-> system status mariadb (to check whether is in running state or not then ull get the option to create password)

NOW YOU ARE READY TO START A NEW JOURNEY OF MYSQL

Gradin answered 23/11, 2023 at 20:14 Comment(0)
C
0

It's work for me

Image: python:3.6.15-slim-buster

wget https://dev.mysql.com/get/mysql-apt-config_0.8.26-1_all.deb
dpkg -i mysql-apt-config_0.8.26-1_all.deb
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B7B3B788A8D3785C
echo "deb http://repo.mysql.com/apt/debian/ buster mysql-8.0" >> /etc/apt/sources.list.d/mysql.list
apt-get update
apt-get install -y --no-install-recommends mysql-server

Refer: https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/#apt-repo-fresh-install

Culch answered 9/2 at 13:22 Comment(0)
C
0

On Debian 12 I only had to update to ensures that the system has the latest information about the available packages:

sudo apt update
Commination answered 5/3 at 13:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.