Instalação do servidor mysql após mariadb falhar

3

Usando o Kubuntu 17.04. Eu tentei instalar o mariadb, que não funcionou, então agora estou tentando reverter para o mysql. No entanto, quando tento instalar o mysql, ele não está mais funcionando:

~# apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
mysql-server is already the newest version (5.7.19-0ubuntu0.17.04.1).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
 mysql-server : Depends: mysql-server-5.7 but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Então eu tentei a sugestão --fix-broken:

~# apt-get --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  mysql-server-5.7
Suggested packages:
  tinyca
The following NEW packages will be installed
  mysql-server-5.7
0 to upgrade, 1 to newly install, 0 to remove and 0 not to upgrade.
5 not fully installed or removed.
Need to get 3,363 kB of archives.
After this operation, 50.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://gb.archive.ubuntu.com/ubuntu zesty-updates/main amd64 mysql-server-5.7 amd64 5.7.19-0ubuntu0.17.04.1 [3,363 kB]
Fetched 3,363 kB in 1s (3,049 kB/s)           
Preconfiguring packages ...
Selecting previously unselected package mysql-server-5.7.
(Reading database ... 304498 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
invoke-rc.d returned 5
There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Estou um pouco preso agora. Alguém pode me ajudar a estabilizar meu sistema novamente?

Atualização: tentou executar os comandos sugeridos, mas isso não resolveu o problema:

~$ sudo service mysql stop
Failed to stop mysql.service: Unit mysql.service not loaded.

~$ sudo apt -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  mysql-server-5.7
Suggested packages:
  tinyca
The following NEW packages will be installed
  mysql-server-5.7
0 to upgrade, 1 to newly install, 0 to remove and 5 not to upgrade.
5 not fully installed or removed.
Need to get 0 B/3,363 kB of archives.
After this operation, 50.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Preconfiguring packages ...
(Reading database ... 304498 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
invoke-rc.d returned 5
There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

~$ sudo pkill mysqld
~$ sudo killall mysqld
mysqld: no process found

~$ sudo apt -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  mysql-server-5.7
Suggested packages:
  tinyca
The following NEW packages will be installed
  mysql-server-5.7
0 to upgrade, 1 to newly install, 0 to remove and 5 not to upgrade.
5 not fully installed or removed.
Need to get 0 B/3,363 kB of archives.
After this operation, 50.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Preconfiguring packages ...
(Reading database ... 304498 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
invoke-rc.d returned 5
There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
    
por Kees 16.08.2017 / 07:34

1 resposta

5

Eu enfrentei o mesmo problema ao tentar atualizar o MySQL para o MariaDB no Ubuntu 17.04 Foi impossível instalar o MariaDB porque o script de pós-instalação achou que ele não conseguiu iniciar o servidor (erro de tempo limite, mas o servidor foi iniciado ). Era impossível reverter para o MySQL porque o script de instalação achava que não poderia parar o servidor mesmo se estivesse realmente parado .

Desinstalar com o apt é difícil e exagerado, já que ele tenta desinstalar todos os pacotes, dependendo das bibliotecas clientes do MySQL.

Aqui está a minha solução para reverter para o MySQL e depois fazer o upgrade para o MariaDB.

1) Detectar todos os pacotes do MariaDB e do MySQL

apt search mariadb | grep "\[install"

e

apt search mysql | grep "\[install"

2) Força a desinstalação de todos os pacotes do MariaDB e do MySQL (servidor, cliente, libs) para limpar a bagunça

sudo dpkg --force depends --purge <package> <package> ...

3) Limpe os dados restantes em / etc e / var / lib / mysql

NB: Primeiro tentei instalar o MariaDB ou o MySQL com meus arquivos de configuração e de dados, mas falhei a cada vez.

sudo rm -rf /var/lib/mysql* /etc/mysql

Se você quiser manter o MySQL e não tiver uma cópia do seu / var / lib / mysql em /var/lib/mysql-5.7 a partir da primeira tentativa de upgrade do MariaDB, você deve apenas mover / var / lib / mysql /var/lib/mysql-5.7 em vez de removê-lo.

4) Corrigir o sistema

sudo apt-get --fix-broken install
sudo apt autoremove
sudo reboot

5) Recupere os dados do MySQL

A instalação do --fix-broken havia reinstalado um MySQL limpo (não um MariaDB, já que o Ubuntu parece gostar desse jeito).

sudo service mysql stop
mv /var/lib/mysql*5.7 /var/lib/mysql
sudo service mysql start

Se você quiser ir para a etapa 6, deverá fazer o backup de todos os seus bancos de dados agora .

6) Finalmente atualize para o MariaDB

Se você já tinha backups, você pode pular a etapa 5.

sudo apt-get install mariadb-server

Sim, foi o que tentei no início, mas desta vez funciona ! Você pode recriar seus usuários de banco de dados e restaurar seus bancos de dados, uma vez que o MariaDB não deseja atualizar as bases do MySQL 5.7.

    
por ChrisAga 21.08.2017 / 21:07