web-dev-qa-db-fra.com

Impossible de mettre à jour ni de supprimer MySQL après la mise à jour d'Ubuntu

il y a deux jours, j'ai mis à jour mon serveur vers la version Xenial et, pour une raison quelconque, la configuration de MySQL a été totalement brisée. J'ai donc essayé de le mettre à jour, de le supprimer et comme cela n'a pas fonctionné, j'ai essayé beaucoup d'idées trouvées en ligne ... Mais aucune n'a fonctionné et je suis toujours aux prises avec ce problème d'installation de MySQL. Donc, je suppose qu'il est temps de demander de l'aide ...

Voici quelques informations qui peuvent aider à identifier le problème:

Sudo apt-get installer 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)

Avez-vous une idée pour résoudre ce problème?

Merci pour votre temps.

--- EDIT ---

Pour tenter de résoudre le problème, tous les fichiers my.cnf ont été supprimés. J'ai donc essayé d'en créer un nouveau dans/etc/mysql en utilisant le contenu suivant, mais cela n'a pas aidé à résoudre mon problème (l'erreur est revenue lorsque j'essaie de "Sudo apt-get installer mysql-server mysql-client" est Toujours le même).

#
# 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 installer 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 installer 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
Valkea

L'installation de mysql-server-5.7 a échoué car:

erreur: le chemin alternatif /etc/mysql/mysql.cnf n'existe pas

Cette erreur peut être causée par un bogue d'installation de mysql.

Je suppose que /etc/mysql/my.cnf existe, mais pas /etc/mysql/mysql.cnf. Donc, les étapes suivantes pourraient aider:

  1. Créer un lien symbolique à partir de /etc/mysql/my.cnf est un lien symbolique vers /etc/alternatives/my.cnf avec cette commande: ln -s /etc/mysql/my.cnf /etc/alternatives/my.cnf

  2. Vérifiez si le lien symbolique par défaut de /etc/alternatives/my.cnf à /etc/mysql/mysql.cnf est intact: ls -l /etc/alternatives/my*

  3. si la sortie indique 'aucun fichier ou répertoire de ce type', créez le lien symbolique avec la commande suivante: ln -s /etc/alternatives/my.cnf /etc/mysql/mysql.cnf

  4. Maintenant, lancez à nouveau l'installation de mysql-server.


[MODIFIER]

Euh, oh. On dirait que la désinstallation précédente s'est mal déroulée. Corrigeons les erreurs une à une jusqu'à ce que vous puissiez installer correctement mysql à nouveau. Erreur actuelle:

chown: utilisateur invalide: ‘mysql: mysql’

Pour résoudre ce problème, vérifions (et s'il manque une création) que l'utilisateur 'mysql' et son groupe 'mysql':

  • Ouvrir le fichier de groupe pour le modifier: Sudo vi /etc/group (soyez prudent lors de la modification de ce fichier!)
  • Cherchez une ligne commençant par 'mysql'.

    • a) S'il y en a un, rappelez-vous le nombre à la fin de cette ligne.
    • b) S'il n'y a pas de telle ligne 'mysql', cherchez la ligne avec le plus grand nombre 1xx dans toute la liste (!). ajoutez une nouvelle ligne après cela et entrez 'mysql: x: GGG' (remplacez GGG par le plus grand nombre 1xx +1). votre ligne ajoutée pourrait ressembler à ceci par exemple: mysql: x: 115. Puis enregistrez et quittez ce fichier.
  • Maintenant, ouvrez 'vi/etc/passwd' (encore une fois, soyez prudent en modifiant ce fichier!)
  • Cherchez une ligne avec 'mysql'.

    • a) s'il y en a un, vérifiez le 2e chiffre de cette ligne. Il doit correspondre au numéro que vous avez mémorisé/ajouté auparavant dans le fichier de groupe.
    • b) s'il n'y a pas de telle ligne 'mysql', cherchez la ligne avec le plus grand nombre 1xx dans la liste wohle (!). ajoutez une nouvelle ligne après cela et entrez 'mysql: x: UUU: GGG: Serveur MySQL ,:/non existant:/bin/false' (remplacez UUU par le plus grand nombre 1xx de ce fichier. remplacez GGG par le numéro mémorisé/ajouté du fichier de groupe avant). Puis enregistrez et quittez ce fichier.

    • Maintenant, essayez d'installer mysql-server à nouveau.

2
Bob