Unable to locate package mysql-server

I installed ubuntu 16.04, after that when i try to install mysql it shows error as

$ sudo apt-get update
[sudo] password for mcerc:
Reading package lists... Done
mcerc@mcerc-ThinkCentre-M72e:~$ sudo apt-get install mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package mysql
mcerc@mcerc-ThinkCentre-M72e:~$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package mysql-server
mcerc@mcerc-ThinkCentre-M72e:~$ ^C
mcerc@mcerc-ThinkCentre-M72e:~$ 
1

5 Answers

Whenever u install fresh Ubuntu , you need to update and upgrade the system to install from ubuntu repositories.

sudo apt-get update && sudo apt-get dist-upgrade

Now install anything

 sudo apt-get install mysql-server
3
  • First, goto Ubuntu Software and in the menu there will be the option Ubuntu Software. Select it.
  • There, you will Softwares and Updates. Select it. Check if all the official repositories (under the option Ubuntu Software) are checked. If not then check them.
  • Else use the following command for installing mysql-server sudo apt install mysql-server-5.7. This should work.

UPDATE: Ubuntu Software tab is moved to Software & Update, a separate application in Ubuntu 18.04

1

Your problem : mysql-server maybe was installed once and the settings in your machine might be saved somewhere . Remove it completely with .

Uninstall mysql-server first:

sudo apt-get remove --purge mysql-server 

install it again. Run this command:

sudo apt-get install mysql-server

This also help to fix broken packages, so if these commands above failed tried to fix packages first and then remove and install the mysql-server:

sudo apt-get -f install
1

Thank you for this. I had an issue installing openssh-server on my Ubuntu 16. I tried above solution and it installs openssh-server successfully. Here is what I tries:

sudo apt-get update && sudo apt-get dist-upgrade
sudo apt-get remove --purge openssh-server
sudo apt-get install openssh-server
sudo apt-get -f install

Hope this will help someone.

1

The other answers should work normally, but for me something was circularly misconfigured somehow and sudo apt purge mysql* -yjust gave me

E: Unable to locate package mysql-apt-config_0.8.9-1_all.deb

but alsosudo apt-get update && sudo apt-get dist-upgrade
just gave me

dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
mysql-server-8.0
E: Sub-process /usr/bin/dpkg returned an error code (1)

So I thought if apt can't handle it on it's own, I'll bring on the big guy: dpkg

First I queried all packages containing mysql with

sudo dpkg-query -l | less | grep mysql

then I purged all of them one by one like

sudo dpkg --purge mysql-common
sudo dpkg --purge mysql-server-8.0
sudo dpkg --purge mysql-server-core-8.0
...

Then I ran all the commands suggested here + sudo apt autoremove, so after that I could reinstall it just like normal.

Hope this will help someone.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like