15

I failed to upgrade MySQL server. Here's what I tried:

I first issue this command to update the package list:

sudo apt-get update

Then, upgrade by:

sudo apt-get upgrade

It shows the following error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 mysql-server-5.5 : Depends: mysql-server-core-5.5 (= 5.5.28-0ubuntu0.12.04.2) but 5.5.31-0ubuntu0.12.04.1 is installed
E: Unmet dependencies. Try using -f.

Apparently a newer version is installed (but why? I didn't install manually). Okay, As it suggests, I issue the command to attempt fixing:

sudo apt-get -f install

Here is the output:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  mysql-server mysql-server-5.5
Suggested packages:
  tinyca mailx
The following packages will be upgraded:
  mysql-server mysql-server-5.5
2 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
2 not fully installed or removed.
Need to get 0 B/8889 kB of archives.
After this operation, 64.5 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_HK.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
dpkg: dependency problems prevent configuration of mysql-server-5.5:
 mysql-server-5.5 depends on mysql-server-core-5.5 (= 5.5.28-0ubuntu0.12.04.2); however:
  Version of mysql-server-core-5.5 on system is 5.5.31-0ubuntu0.12.04.1.
dpkg: error processing mysql-server-5.5 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                          dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.
dpkg: error processing mysql-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                          Errors were encountered while processing:
 mysql-server-5.5
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

Then I try to use another command that some people suggest in the Internet:

sudo apt-get -f upgrade

Same output is produced. Apart from re-installing MySQL server, what else can I do ?

using Ubuntu server 12.04 LTS

Braiam
  • 67,791
  • 32
  • 179
  • 269
Raptor
  • 375
  • 1
    no idea if it will work, but did you try dist-upgrade instead of upgrade? – strugee May 09 '13 at 04:43
  • That saved my day! Clear steps.

    http://www.randomhacks.co.uk/mysql-job-failed-to-start-unable-to-set-root-password-cant-find-file-mysql/

    – ses Apr 15 '14 at 21:23
  • Similar question: http://askubuntu.com/questions/697805/package-mysql-server-5-5-is-not-configured-yet – Suragch Nov 14 '15 at 02:48

1 Answers1

29

That happened to me but it was that, after doing a sudo apt-get update it somehow did not get the newest version of the mysql-server, only of the mysql-server-core. I would first suggest to do another sudo apt-get update and then proceed on installing the package

sudo apt-get install mysql-server

If that does not work then do a reinstall:

sudo apt-get install --reinstall mysql-server

And if that does not work, then simply purge the package mysql-server-core package, then install mysql-server again.

sudo apt-get purge mysql-server-core mysql-server-core-5.5

sudo apt-get install mysql-server

And if that does not work then go crazy on it with:

sudo apt-get clean

sudo apt-get autoclean

sudo apt-get purge mysql-server*

sudo apt-get install mysql-server

As a last resort, I would purge, reboot, install.

Luis Alvarado
  • 211,503
  • 2
    Thanks, but will it delete the database schema during re-install ? – Raptor May 09 '13 at 05:58
  • 4
    No it won't. Even purging will not touch your already created database schemes. It will however overkill whatever problem you are having. – Luis Alvarado May 09 '13 at 16:08
  • Note: purge will ask for a new mysql root password – elomage Feb 06 '14 at 15:32
  • in my case, after all those steps. "Unable to set password for mysql "root" user ". and then fails with: Errors were encountered while processing: mysql-server-5.5 mysql-server E: Sub-process /usr/bin/dpkg returned an error code (1) – ses Apr 15 '14 at 19:26
  • @ses did you search askubuntu for that error. I mean for that "Unable to set password for mysql" error. I got several that already have the answer I was going to say. – Luis Alvarado Apr 15 '14 at 21:50
  • 1
    That helped me. http://www.randomhacks.co.uk/mysql-job-failed-to-start-unable-to-set-root-password-cant-find-file-mysql/ – ses Apr 15 '14 at 21:56
  • 1
    You are on some next level Luis, thanks for this (had to go crazy too) – a7omiton Nov 01 '14 at 18:59
  • great post, love it. very much helpful. – StreetCoder Nov 18 '15 at 03:39
  • 1
    Similar problem after an upgrade of Ubuntu 18.04 to 20.04. Had to do the go crazy method but the difference on my system was that mysql-server-5.7* was still lingering. So my go crazy was more radical and involved apt-get purge mysql – Eugene van der Merwe Jan 14 '21 at 00:42
  • The randomhacks.co.uk solution in the comment by @ses resolved my issue too. I was getting multiple dpkg: too many errors messages using apt-get but purging from dpkg worked first time. – edwinbradford Aug 18 '23 at 14:27