26

I'm a newbie here so please bear with me.

I'm using ubuntu 14.04.

I tried entering mysql with the following command:

mysql -u root -p

and I got the following message:

The program mysql can be found on the following packages:
* mysql-client-core-5.5 
* mariadb-client-core-5.5 
* mysql-client-core-5.6 
* percona-xtrabd-cluster-client-5.5 

I then typed in:

sudo apt-get install mysql-client-core-5.6

After this was installed, I tried connecting to mysql again using:

mysql -u root -p

I then got the error message:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

After searching online, I found out I needed to install mysql server and so I wrote in the following command

sudo apt-get install mysql-server

I then got the message:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 mysql-server : Depends: mysql-server-5.5 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I've been looking on line for the past hour for a solution but other people who had a similar error but had it from upgrading mysql and thus there solution were ineffective for me.

  • Try sudo apt-get install --fix-missing --force – aroll605 Jun 30 '14 at 3:57
  • I tried this and it works. I'm not quite sure if it can help you. – Ai Kudou Apr 29 '19 at 9:33
43

Open the terminal and type:

sudo apt-get purge mysql-client-core-5.6
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt install mysql-client-core-5.5
sudo apt install mysql-server  

Both MySQL database core client and MySQL Server packages will be the same version 5.5. MySQL Client 5.5 and MySQL Server 5.5 are the current "best" versions of these packages in Ubuntu 14.04 as determined by the package maintainers. If you would rather install MySQL Client 5.6 and MySQL Server 5.6 you can also find the mysql-client-core-5.6 and mysql-server-5.6 packages in the Ubuntu Software Center. The important thing is that the client and server version numbers match in either case.

In Ubuntu 16.04 and 18.04 the names of these two packages are mysql-client-core-5.7 and mysql-server-5.7.

| improve this answer | |
  • nope, same stuff mysql-server : Depends: mysql-server-5.5 but it is not going to be installed. E: Unable to correct problems, you have held broken packages. – Toolkit Feb 10 '18 at 13:04
  • @Toolkit Fix that error like this: E: Unable to correct problems, you have held broken packages In Ubuntu 16.04 it's mysql-client-core-5.7 and mysql-server-5.7. – karel Feb 10 '18 at 13:20
  • Thanks A Ton! Mate, you are a Savior! BrAvo!!!!! – Rahul May 24 at 7:44
8

Following command has solved my problem.

sudo aptitude install mysql-server

If aptitude is not installed in your computer, first install aptitude using following command.

sudo apt-get install aptitude
| improve this answer | |
  • Imho, this will not solve the problem. See explanation of @karel. – Jonas Gröger Mar 17 '15 at 10:18
  • 1
    It solved the problem for me and @karel's didn't. – acsadam0404 Apr 23 '16 at 11:31
1

I solved this problem using Synaptic Package Manager.

I figured out that, in my case, I'm using different versions of MySQL common, server and client sides.

In particular, for common I was using a mariabd repository to get the file. I've change this using Package > Force version in Synaptic and choosing the same version (5.7.12) for all packages.

Hope this help.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.