2

two days ago I updated my server to the Xenial version and for some reason it totally broke my MySQL configuration. So, I tried to update it, remove it, and as it didn't worked I tried many ideas I found online... But none worked and I'm still stuck with this MySQL installation problem. So I guess it's time to ask for some help...

Here is some informations that may help identifying the problem:

sudo apt-get install mysql-server mysql-client

Reading package lists... Done
Building dependency tree       
Reading state information... Done
mysql-client is already the newest version (5.7.21-0ubuntu0.16.04.1).
mysql-server is already the newest version (5.7.21-0ubuntu0.16.04.1).
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Setting up mysql-server-5.7 (5.7.21-0ubuntu0.16.04.1) ...
update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package 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.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

sudo apt-get purge mysql*

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'mysqltcl' for glob 'mysql*'
Note, selecting 'mysql-mmm-agent' for glob 'mysql*'
Note, selecting 'mysql-workbench' for glob 'mysql*'
Note, selecting 'mysql-client-5.1' for glob 'mysql*'
Note, selecting 'mysql-client-5.5' for glob 'mysql*'
Note, selecting 'mysql-client-5.6' for glob 'mysql*'
Note, selecting 'mysql-client-5.7' for glob 'mysql*'
Note, selecting 'mysql-mmm-tools' for glob 'mysql*'
Note, selecting 'mysql-common-5.6' for glob 'mysql*'
Note, selecting 'mysql-server-5.0' for glob 'mysql*'
Note, selecting 'mysql-server-5.1' for glob 'mysql*'
Note, selecting 'mysql-server-5.5' for glob 'mysql*'
Note, selecting 'mysql-server-5.6' for glob 'mysql*'
Note, selecting 'mysql-server-5.7' for glob 'mysql*'
Note, selecting 'mysql-utilities' for glob 'mysql*'
Note, selecting 'mysql-testsuite' for glob 'mysql*'
Note, selecting 'mysql-mmm-common' for glob 'mysql*'
Note, selecting 'mysql-server' for glob 'mysql*'
Note, selecting 'mysql-client' for glob 'mysql*'
Note, selecting 'mysql-sandbox' for glob 'mysql*'
Note, selecting 'mysql-client-core-5.5' for glob 'mysql*'
Note, selecting 'mysql-client-core-5.6' for glob 'mysql*'
Note, selecting 'mysql-client-core-5.7' for glob 'mysql*'
Note, selecting 'mysql-testsuite-5.5' for glob 'mysql*'
Note, selecting 'mysql-testsuite-5.6' for glob 'mysql*'
Note, selecting 'mysql-testsuite-5.7' for glob 'mysql*'
Note, selecting 'mysql-common' for glob 'mysql*'
Note, selecting 'mysql-mmm-monitor' for glob 'mysql*'
Note, selecting 'mysqltuner' for glob 'mysql*'
Note, selecting 'mysql-workbench-data' for glob 'mysql*'
Note, selecting 'mysql-server-core-5.1' for glob 'mysql*'
Note, selecting 'mysql-server-core-5.5' for glob 'mysql*'
Note, selecting 'mysql-server-core-5.6' for glob 'mysql*'
Note, selecting 'mysql-server-core-5.7' for glob 'mysql*'
Note, selecting 'mysql-source-5.7' for glob 'mysql*'
Package 'mysql-client-5.5' is not installed, so not removed
Package 'mysql-client-5.6' is not installed, so not removed
Package 'mysql-server-core-5.6' is not installed, so not removed
Package 'mysql-client-core-5.5' is not installed, so not removed
Package 'mysql-client-core-5.6' is not installed, so not removed
Note, selecting 'mysql-common' instead of 'mysql-common-5.6'
Package 'mysql-server-5.6' is not installed, so not removed
Package 'mysql-server-core-5.5' is not installed, so not removed
Package 'mysql-testsuite-5.5' is not installed, so not removed
Package 'mysql-testsuite-5.6' is not installed, so not removed
Package 'mysql-server-5.0' is not installed, so not removed
Package 'mysql-server-5.1' is not installed, so not removed
Package 'mysql-server-core-5.1' is not installed, so not removed
Package 'mysql-client-5.1' is not installed, so not removed
Package 'mysql-mmm-agent' is not installed, so not removed
Package 'mysql-mmm-common' is not installed, so not removed
Package 'mysql-mmm-monitor' is not installed, so not removed
Package 'mysql-mmm-tools' is not installed, so not removed
Package 'mysql-sandbox' is not installed, so not removed
Package 'mysql-utilities' is not installed, so not removed
Package 'mysql-workbench' is not installed, so not removed
Package 'mysql-workbench-data' is not installed, so not removed
Package 'mysqltcl' is not installed, so not removed
Package 'mysqltuner' is not installed, so not removed
Package 'mysql-source-5.7' is not installed, so not removed
Package 'mysql-testsuite' is not installed, so not removed
Package 'mysql-testsuite-5.7' is not installed, so not removed
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:
 mariadb-client : Depends: mariadb-client-10.0 (>= 10.0.33-0ubuntu0.16.04.1) but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

d pkg -l | grep -i mysql

ii  dbconfig-mysql                     2.0.4ubuntu1                               all          dbconfig-common MySQL/MariaDB support
ii  libdbd-mysql-perl                  4.033-1ubuntu0.1                           amd64        Perl5 database interface to the MySQL database
ii  libmysqlclient-dev                 5.7.21-0ubuntu0.16.04.1                    amd64        MySQL database development files
ii  libmysqlclient18:amd64             5.5.53-0ubuntu0.14.04.1                    amd64        MySQL database client library
ii  libmysqlclient20:amd64             5.7.21-0ubuntu0.16.04.1                    amd64        MySQL database client library
ii  mysql-client                       5.7.21-0ubuntu0.16.04.1                    all          MySQL database client (metapackage depending on the latest version)
ii  mysql-client-5.7                   5.7.21-0ubuntu0.16.04.1                    amd64        MySQL database client binaries
ii  mysql-client-core-5.7              5.7.21-0ubuntu0.16.04.1                    amd64        MySQL database core client binaries
ii  mysql-common                       5.7.21-0ubuntu0.16.04.1                    all          MySQL database common files, e.g. /etc/mysql/my.cnf
iU  mysql-server                       5.7.21-0ubuntu0.16.04.1                    all          MySQL database server (metapackage depending on the latest version)
rc  mysql-server-5.5                   5.5.53-0ubuntu0.14.04.1                    amd64        MySQL database server binaries and system database setup
iF  mysql-server-5.7                   5.7.21-0ubuntu0.16.04.1                    amd64        MySQL database server binaries and system database setup
ii  mysql-server-core-5.7              5.7.21-0ubuntu0.16.04.1                    amd64        MySQL database server binaries
ii  mytop                              1.9.1-2                                    all          top like query monitor for MySQL
ii  php-mysql                          1:7.0+35ubuntu6                            all          MySQL module for PHP [default]
ii  php5-mysql                         5.5.9+dfsg-1ubuntu4.20                     amd64        MySQL module for php5
ii  php7.0-mysql                       7.0.22-0ubuntu0.16.04.1                    amd64        MySQL module for PHP
ii  phpmyadmin                         4:4.5.4.1-2ubuntu2                         all          MySQL web administration tool

sudo apt-get purge dbconfig-mysql

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  dbconfig-no-thanks
The following packages will be REMOVED:
  dbconfig-mysql*
The following NEW packages will be installed:
  dbconfig-no-thanks
0 upgraded, 1 newly installed, 1 to remove and 17 not upgraded.
2 not fully installed or removed.
Need to get 1,314 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 mirror://mirrors.ubuntu.com/mirrors.txt xenial/universe amd64 dbconfig-no-thanks all 2.0.4ubuntu1 [1,314 B]
Fetched 1,314 B in 1s (994 B/s)         
dpkg: dbconfig-mysql: dependency problems, but removing anyway as you requested:
 phpmyadmin depends on dbconfig-mysql | dbconfig-no-thanks | dbconfig-common (<< 2.0.0); however:
  Package dbconfig-mysql is to be removed.
  Package dbconfig-no-thanks is not installed.
  Version of dbconfig-common on system is 2.0.4ubuntu1.

(Reading database ... 81675 files and directories currently installed.)
Removing dbconfig-mysql (2.0.4ubuntu1) ...
Selecting previously unselected package dbconfig-no-thanks.
(Reading database ... 81673 files and directories currently installed.)
Preparing to unpack .../dbconfig-no-thanks_2.0.4ubuntu1_all.deb ...
Unpacking dbconfig-no-thanks (2.0.4ubuntu1) ...
Setting up mysql-server-5.7 (5.7.21-0ubuntu0.16.04.1) ...
update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 2
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.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Setting up dbconfig-no-thanks (2.0.4ubuntu1) ...
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

Do you have any idea to solve this issue?

Thank you for your time.

---EDIT---

In an attempt to fix the problem, all the my.cnf files deleted. So I tried to create a new one in /etc/mysql using the following content, but it didn't help to fix my problem (the error returned when I try to "sudo apt-get install mysql-server mysql-client" is still the same).

#
# 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/

---EDIT 2---

ln -s /etc/alternatives/my.cnf /etc/mysql/mysql.cnf

sudo apt-get install mysql-server mysql-client

Reading package lists... Done
Building dependency tree       
Reading state information... Done
mysql-client is already the newest version (5.7.21-0ubuntu0.16.04.1).
mysql-server is already the newest version (5.7.21-0ubuntu0.16.04.1).
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Setting up mysql-server-5.7 (5.7.21-0ubuntu0.16.04.1) ...
update-alternatives: warning: /etc/alternatives/my.cnf has been changed (manually or by a script); switching to manual updates only
update-alternatives: warning: forcing reinstallation of alternative /etc/mysql/my.cnf because link group my.cnf is broken
update-alternatives: warning: current alternative /etc/mysql/my.cnf is unknown, switching to /etc/mysql/mysql.cnf for link group my.cnf
update-alternatives: warning: not replacing /etc/mysql/my.cnf with a link
chown: invalid user: ‘mysql:mysql’
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
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.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

---EDIT 3---

sudo apt-get install mysql-server mysql-client

Reading package lists... Done
Building dependency tree       
Reading state information... Done
mysql-client is already the newest version (5.7.21-0ubuntu0.16.04.1).
mysql-server is already the newest version (5.7.21-0ubuntu0.16.04.1).
0 upgraded, 0 newly installed, 0 to remove and 35 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Setting up mysql-server-5.7 (5.7.21-0ubuntu0.16.04.1) ...
update-alternatives: error: cannot stat file '/etc/mysql/mysql.cnf': Too many levels of symbolic links
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package 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.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
2

Installation of mysql-server-5.7 failed because:

error: alternative path /etc/mysql/mysql.cnf doesn't exist

This error might be caused by a mysql installation bug.

I assume /etc/mysql/my.cnf does exist, but /etc/mysql/mysql.cnf does not. So the following steps might help:

  1. Create a symlink from /etc/mysql/my.cnf is a symlink to /etc/alternatives/my.cnf with this command: ln -s /etc/mysql/my.cnf /etc/alternatives/my.cnf

  2. Check if default symlink from /etc/alternatives/my.cnf to /etc/mysql/mysql.cnf is intact: ls -l /etc/alternatives/my*

  3. if output shows 'no such file or directory', create the symlink with this command: ln -s /etc/alternatives/my.cnf /etc/mysql/mysql.cnf

  4. Now run the mysql-server installation again.


[EDIT]

Uh, oh. Looks like pretty much went wrong with the previous uninstall. Let's fix the errors one by one until you can get mysql installed correctly again. Current error:

chown: invalid user: ‘mysql:mysql’

To fix that, let's check (and if missing create) that 'mysql' user and it's 'mysql' group:

  • Open group file for edit: sudo vi /etc/group(be careful editing that file!)
  • Look for a line starting with 'mysql'.

    • a) If it's there, remember the number at the end of that line.
    • b) If there is no such 'mysql' line then look for the line with highest 1xx number in the whole(!) list. add a new line after that and enter 'mysql:x:GGG' (replace GGG with the highest 1xx number +1). your added line could look like this for example: mysql:x:115. Then save and quit that file.
  • Now open 'vi /etc/passwd' (again. be careful editing that file, too!)
  • Look for a line with 'mysql'.

    • a) if it's there, check the 2nd number in that line. It has to match the number you remembered/added before in the group file.
    • b) if there's no such 'mysql' line then look for the line with the highest 1xx number in the wohle(!) list. add a new line after that and enter 'mysql:x:UUU:GGG:MySQL Server,,,:/nonexistent:/bin/false' (replace UUU with the highest number 1xx number +1 from this file. replace GGG with the remembered/added number from group file before.). Then save and quit that file.

    • Now try to install mysql-server again.

10
  • I tried and it failed. My /etc/mysql/my.cnf (all all other my.cnf files) was deleted in a previous attempt to fix this problem... So I created a new one (see my edit for the content of this new file). And then I created the symlink and checked it as suggested, but it didn't work. – Valkea Feb 8 '18 at 17:15
  • What error does the install command show this time? – Bob Feb 8 '18 at 17:31
  • Hum, I guess I missed the point 3 in your step by step guide. Sorry... I will try with this extra step. – Valkea Feb 8 '18 at 17:38
  • There is still an error message, but it changed (I will edit the main question and add this new output) – Valkea Feb 8 '18 at 17:41
  • Now it's getting a bit more complex. I've added more instructions to my answer to help you. But be careful editing those two files mentioned! – Bob Feb 8 '18 at 18:16

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.