41

I have trouble in installing or removing the partly installed mysql-server-5.6 in ubuntu15.04. The error I am getting was

$ sudo apt-get -f install 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  mysql-server-5.6
The following packages will be upgraded:
  mysql-server-5.6
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
22 not fully installed or removed.
Need to get 0 B/5,501 kB of archives.
After this operation, 50.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Preconfiguring packages ...
Setting up mysql-common (5.6.24-0ubuntu2) ...
update-alternatives: error: alternative path                 /etc/mysql/my.cnf.fallback doesn't exist
dpkg: error processing package mysql-common (--configure):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 mysql-common
localepurge: Disk space freed in /usr/share/locale: 0 KiB
localepurge: Disk space freed in /usr/share/man: 0 KiB
localepurge: Disk space freed in /usr/share/gnome/help: 0 KiB
localepurge: Disk space freed in /usr/share/omf: 0 KiB
localepurge: Disk space freed in /usr/share/doc/kde/HTML: 0 KiB

Total disk space freed by localepurge: 0 KiB

E: Sub-process /usr/bin/dpkg returned an error code (1)

Can someone help me on this?

3
  • Better can remove and hopefully a clean re-install would be fine i think.
    – BDRSuite
    Jul 1, 2015 at 18:06
  • I tried this process still i have the problem, ie i am ubable to uninstall or reinstall mysql server Jul 2, 2015 at 5:24
  • 1
    I tried my level best to find out the cause for the issue. I removed the data from the apt status file and updated the apt, where I noticed the system is experiencing the problem with libgcc1 libc6. I am trying to solve the problem Will keep post the status based on my findings. Jul 2, 2015 at 6:03

9 Answers 9

79

Try doing a purge, then re-install.

sudo apt-get remove --purge mysql-\*
sudo apt-get install mysql-server mysql-client

Update 04.09.2018:
If you have issues uninstalling/installing because MySQL process is live, you can try this first, then above:
sudo kill $(pgrep mysql)

5
  • I tried this process still i have the problem, ie i am ubable to uninstall or reinstall mysql server Jul 2, 2015 at 5:23
  • 1
    The original instructions removed the metapackage, which was a no-op. The new edited instructions work with 16.04.
    – mrm
    Jul 24, 2016 at 16:33
  • Worked for me on elementary OS.
    – MChaker
    Dec 18, 2016 at 7:41
  • 3
    This worked for me only after I checked ps -aef | grep mysql and sent a kill signal to all varieties of running mysqld. Jan 11, 2017 at 20:10
  • Thanks for the tip about killing mysql! I had uninstalled it but somehow it was still running (???) and then my new install got stuck on 94% around Installing new version of config file /etc/mysql/mysql.conf.d/mysqld.cnf ...update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode But killing mysql did it! Apr 28, 2020 at 15:29
19

A very simple solution which I (the linux noob) had to dig up... is to create the file.

nano /etc/mysql/my.cnf.fallback

and fill it with the default content from the mysql-common 5.7.11-0ubuntu6 package.

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

!includedir /etc/mysql/conf.d/

found here at apt-browse.org

2
  • This is a better answer than the accpeted one because it fixes the actual problem without having to use the brute force approach.
    – devius
    Jan 30, 2018 at 19:04
  • 1
    In my case touch /etc/mysql/my.cnf.fallback got me past the issue.
    – oalders
    Sep 21, 2018 at 1:59
11

Purge/Reinstall also did not work for me. I found the following "solution":

I could not find mysql.cnf.fallback listed in the "provided files" for mysql-server-5.6 / mysql-client-5.6 nor any additional info about the file.

I copied /etc/mysql/my.cnf to /etc/mysql/my.cnf.fallback (guessing that this would have been a relatively less important "fallback" config file);

/etc/mysql/my.cnf is a symlink, so ls /etc/mysql now shows:

 my.cnf.fallback -> /etc/alternatives/my.cnf
 my.cnf -> /etc/alternatives/my.cnf

The installation of the package then completed without error (since presumably the "doesn't exist" issue was "solved").

I have not come across any adverse effects (yet).

1
  • This sounds great but can you explain the reason for the problem, It would be beneficial for others. Aug 28, 2015 at 4:05
8

I had the same problem while trying to purge mysql-server (5.7.14).

In case that the my.cnf* files are missing, you can re-install the package mysql-common, and afterwards, you can purge both (mysql-server & mysql-common)

These my.cnf* files belong to mysql-common package (see bellow):

$ dpkg -L mysql-common | grep cnf
/etc/mysql/my.cnf.fallback
/etc/mysql/conf.d/mysql.cnf


1. Re-install mysql-common

apt-get install --reinstall mysql-common

  1. Purge mysql-common

apt-get purge mysql-common

6

Confirmed. Order matters.

apt remove mysql-* mariadb-* --purge
apt install mysql-common
apt install mariadb-common
apt install mariadb-server
1
  • Thank you. This solved it for me and should be the anwser.
    – cantsay
    Nov 6, 2021 at 18:14
2

As noted by charneykaye in the comments, this approach can fail if there's some mysql processes in the background. I used:

emil-mint-desktop ~ # ps -aef | grep mysql
root      6682     1  0 16:45 ?        00:00:00 sudo mysqld_safe --skip-grant-tables
root      6683  6682  0 16:45 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables
mysql     7046  6683  0 16:45 ?        00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --skip-grant-tables --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306 --log-syslog=1 --log-syslog-facility=daemon --log-syslog-tag=
root     21046  9812  0 17:32 pts/5    00:00:00 grep --color=auto mysql

Killed the first 3 processes (the last one is the grep call itself!) using:

kill -9 6682 8883 7046

Then remove everything mysql related:

apt remove --purge mysql-\*
apt autoremove
apt autoclean

and then install:

apt install mysql-server

Then it worked.

Versions:

  • Mint 18.1 (based on Ubuntu). You will need to substitute apt for apt-get for some other versions.
1
  • Followed these steps and worked on Ubuntu when trying to install mysql-server from the standard apt repo (moving from Oracle's APT repo). The purge step prompted to remove databases and lib files which I denied. It still cleaned up the environment to get mysql-server to install properly. +1 Nov 22, 2023 at 3:33
1

I checked my /etc/mysql/ folder and found it to be completely empty other than an empty sub-folder conf.d.

cd /etc/
# you need to delete the empty mysql folder otherwise the ln below creates the link inside the existing mysql folder
sudo rm -r mysql
sudo ln -s ./mysql.bak/ mysql

then (courtesy of this link this link)

sudo dpkg --configure -a

and now all appears okay.

The link above also mentions --force-depends but I did not need this. It also mentions apt-get -f install but again I did not need this.

1
  • This was exactly my problem. This fixed it for me. Oct 7, 2016 at 12:15
0

I found an easy solution for that:

First step: apt-get install mysql-common --reinstall

Second step: apt-get install mysql-server --reinstall

And it works!

0

After trying all the answers above I was able to fix this problem with:

sudo rm /etc/rc5.d/S03mysql

Then I ran:

sudo apt purge mysql-server mysql-server-5.7 mysql-server-core-5.7
sudo apt-get -f install mysql-server --fix-missing --fix-broken

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .