Como reparar a instalação do pacote corrompido (mysql)

9

Após a atualização para o Ubuntu 16.04, notei que o mysql estava tendo erros incompreensíveis. Convencido, foi uma configuração quebrada, tentei executar uma limpeza do mysql. Isso não parece excluir tudo, então tentei fazer isso sozinho:

sudo rm -r /etc/mysql
sudo rm -r /usr/share/mysql-workbench
sudo rm -r /usr/share/mysql
sudo rm -r /usr/share/mysql-common

Isso foi um erro. Nunca tente fazer isso. Agora o mysql não será instalado corretamente. Eu tentei reinstalar as dependências:

sudo apt-get install --reinstall $(apt-cache depends mysql-server | grep -Po 'Depends:\s+\K[^ ]+$' | tr '\n' ' ' )

E os pacotes em si:

sudo apt install mysql-workbench mysql-server --reinstall

Mas recebo todos os tipos de erros crípticos, como:

sudo apt-get install --reinstall mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not         upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for mysql-server:amd64

e desinstalando

sudo apt-get remove mysql-common
Reading package lists... Done
Building dependency tree       
Reading state information... Done
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:
 libmysqlclient20 : Depends: mysql-common (>= 5.5) but it is not going to be installed
 mariadb-client-core-10.0 : Depends: mariadb-common (>= 10.0.24-7) but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

Ou se eu reconfigurar

sudo dpkg --configure -a
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 112: /usr/share/mysql-common/configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
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

Ou se eu forçar a instalação:

sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 112: /usr/share/mysql-common/configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
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)

Ou se eu fizer uma limpeza:

sudo apt-get -f purge mysql-server 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  mysql-server*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 159 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 348226 files and directories currently installed.)
Removing mysql-server (5.7.12-0ubuntu1) ...
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 112: /usr/share/mysql-common/configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 mysql-server-5.7
E: Sub-process /usr/bin/dpkg returned an error code (1)

O apt não consegue se recuperar de uma instalação parcial? Preciso reinstalar o sistema operacional?

    
por Jonathan 16.05.2016 / 18:20

6 respostas

15

Faça o seguinte para limpar os pacotes quebrados:

sudo apt-get clean
sudo apt-get update
sudo dpkg -r mysql-client-5.7
sudo dpkg -r mysql-server-5.7
sudo dpkg -r libmysqlclient20:i386
sudo dpkg -r libmysqlclient20:amd64
sudo dpkg -r libmysqlclient18:amd64
sudo dpkg -r mysql-common
sudo dpkg -r mysql 

Depois disso, reinstale-o com:

sudo apt-get install mysql mysql-client* mysql-server*
    
por Videonauth 17.05.2016 / 01:26
7

Obrigado ao @Videonauth

sudo dpkg -r mysql-client-5.7
sudo dpkg -r mysql-server-5.7
sudo dpkg -r libmysqlclient20:i386
sudo dpkg -r libmysqlclient20:amd64
sudo dpkg -r libmysqlclient18:amd64
sudo dpkg -r mysql-common

Em seguida, execute:

sudo apt-get purge mysql\* mariadb\* libmysql\* libmariadb\*

Se algo falhar, basta executar sudo dpkg -r <failedpackage> e se isso falhar, remova o pacote que depende dele. Se você repetir, o apt-get eventualmente funcionará novamente.

Veja também Qual é a diferença entre o dpkg e o dpkg? aptitude / apt-get?

    
por Jonathan 17.05.2016 / 01:22
3

Tente isso,

execute este comando para limpar o mysql, substitua a versão 5.7 pela sua versão instalada

sudo apt purge mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7 mysql-server

execute isto para limpar e atualizar pacotes

sudo apt update && sudo apt dist-upgrade && sudo apt autoremove && sudo apt -f install

finalmente instale o mysql

sudo apt install mysql-server

isso funcionou para mim.

    
por rahul 09.07.2017 / 21:16
1

Após purgar mysql como mostrado acima, você precisa instalar o mysql desta forma:

sudo apt-get install mysql-common 
sudo apt-get install mysql-server

Quando você instala dessa maneira, não terá um erro de instalação.

    
por tomek 28.04.2017 / 11:18
1

Isso funcionou para mim

sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade

depois disso eu instalei o mysql novamente com

sudo apt-get install mysql-server e agora está funcionando bem.

    
por Jayakrishnan Menon 13.12.2017 / 06:47
0

O comando sudo dpkg -r não funciona para mim ..

Eu usei sudo apt-get purge mysql-* para desinstalar todo o pageage releated e depois reinstalá-los

    
por Ruijie Yuan 19.04.2018 / 19:41