Não é possível atualizar nem remover o MySQL após a atualização do Ubuntu

1

dois dias atrás eu atualizei meu servidor para a versão do Xenial e por alguma razão ele quebrou totalmente minha configuração do MySQL. Então, tentei atualizá-lo, removê-lo e, como ele não funcionava, tentei muitas ideias que encontrei on-line ... Mas nenhuma funcionou e ainda estou presa a esse problema de instalação do MySQL. Então eu acho que é hora de pedir ajuda ...

Veja algumas informações que podem ajudar a identificar o problema:

sudo apt-get instala o 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 purga 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)

Tem alguma ideia para resolver este problema?

Obrigado pelo seu tempo.

--- EDIT ---

Na tentativa de corrigir o problema, todos os arquivos my.cnf foram excluídos. Então eu tentei criar um novo em / etc / mysql usando o seguinte conteúdo, mas isso não ajudou a consertar meu problema (o erro retornado quando eu tento "sudo apt-get install mysql-server mysql-client" é ainda o mesmo).

#
# 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 instala o 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 instala o 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)
    
por Valkea 08.02.2018 / 17:06

1 resposta

1

A instalação do mysql-server-5.7 falhou porque:

  

erro: caminho alternativo /etc/mysql/mysql.cnf não existe

Este erro pode ser causado por um erro de instalação do mysql.

Eu assumo que /etc/mysql/my.cnf existe, mas /etc/mysql/mysql.cnf não existe. Portanto, as etapas a seguir podem ajudar:

  1. Crie um symlink em /etc/mysql/my.cnf é um link simbólico para /etc/alternatives/my.cnf com este comando: ln -s /etc/mysql/my.cnf /etc/alternatives/my.cnf

  2. Verifique se o symlink padrão de /etc/alternatives/my.cnf para /etc/mysql/mysql.cnf está intacto: ls -l /etc/alternatives/my*

  3. se a saída mostrar 'no such file or directory', crie o symlink com este comando: ln -s /etc/alternatives/my.cnf /etc/mysql/mysql.cnf

  4. Agora execute a instalação do mysql-server novamente.

[EDITAR]

Uh, oh. Parece que deu muito errado com a desinstalação anterior. Vamos corrigir os erros um por um até que você possa instalar o mysql corretamente. Erro atual:

  

chown: usuário inválido: ‘mysql: mysql’

Para corrigir isso, vamos verificar (e se estiver faltando create) que o usuário 'mysql' e o grupo 'mysql':

  • Abra o arquivo do grupo para edição: sudo vi /etc/group (tenha cuidado ao editar esse arquivo!)
  • Procure por uma linha começando com 'mysql'.

    • a) Se estiver lá, lembre-se do número no final dessa linha.
    • b) Se não houver essa linha 'mysql', procure a linha com o maior número 1xx na lista inteira (!). adicione uma nova linha depois disso e digite 'mysql: x: GGG' (substitua GGG pelo maior 1xx numero +1). sua linha adicionada poderia parecer isso por exemplo: mysql: x: 115. Em seguida, salve e saia desse arquivo.
  • Agora abra 'vi / etc / passwd' (novamente, tenha cuidado ao editar esse arquivo também!)
  • Procure por uma linha com 'mysql'.

    • a) se estiver lá, verifique o segundo número nessa linha. Ele precisa corresponder ao número que você lembrou / adicionou antes no arquivo do grupo.
    • b) se não houver essa linha 'mysql', procure a linha com o maior número 1xx na lista wohle (!). adicione uma nova linha depois disso e digite 'mysql: x: UUU: GGG: Servidor MySQL ,: / nonexistent: / bin / false' (substitua o UUU pelo maior número 1xx número +1 desse arquivo. substitua GGG pelo lembrado / adicionado número do arquivo de grupo antes.). Em seguida, salve e saia desse arquivo.

    • Agora tente instalar o mysql-server novamente.

por Bob 08.02.2018 / 18:06