Não é possível instalar ou iniciar o MySQL

1

Estou tentando mover um dos meus projetos de outro VPS, e acho que estraguei meu banco de dados SQL. Tenho certeza que o problema foi iniciado porque há várias instâncias do MySQL no meu VPS, mas estou tendo problemas para remover todos os arquivos.

Então, primeiro, tentei fazer o login no MySQL.

root@fileserver:~# mysql --user=root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Como não há muitas informações importantes no meu banco de dados, eu decidi remover o MySQL fazendo o seguinte

root@fileserver:~# sudo apt-get remove --purge mysql-server mysql-client mysql-common -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libaio1 libevent-core-2.0-5 libnuma1 mysql-client-core-5.7 mysql-server-core-5.7
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  mysql-client* mysql-client-5.7* mysql-common* mysql-server* mysql-server-5.7*
0 upgraded, 0 newly installed, 5 to remove and 18 not upgraded.
2 not fully installed or removed.
After this operation, 82.7 MB disk space will be freed.
(Reading database ... 150440 files and directories currently installed.)
Removing mysql-server (5.7.23-0ubuntu0.16.04.1) ...
Removing mysql-server-5.7 (5.7.23-0ubuntu0.16.04.1) ...
update-alternatives: warning: alternative /etc/mysql/my.cnf.fallback (part of link group my.cnf) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /etc/mysql/mysql.cnf (part of link group my.cnf) doesn't exist; removing from list of alternatives
update-alternatives: warning: /etc/alternatives/my.cnf is dangling; it will be updated with best choice
Purging configuration files for mysql-server-5.7 (5.7.23-0ubuntu0.16.04.1) ...
Removing mysql-client (5.7.23-0ubuntu0.16.04.1) ...
Removing mysql-client-5.7 (5.7.23-0ubuntu0.16.04.1) ...
Removing mysql-common (5.7.23-0ubuntu0.16.04.1) ...
Purging configuration files for mysql-common (5.7.23-0ubuntu0.16.04.1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu21.4) ...
root@fileserver:~# sudo apt-get remove --purge mysql-server mysql-client mysql-common -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'mysql-client' is not installed, so not removed
Package 'mysql-common' is not installed, so not removed
Package 'mysql-server' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  libaio1 libevent-core-2.0-5 libnuma1 mysql-client-core-5.7 mysql-server-core-5.7
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 18 not upgraded.
root@fileserver:~# sudo apt-get autoremove -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  libaio1 libevent-core-2.0-5 libnuma1 mysql-client-core-5.7 mysql-server-core-5.7
0 upgraded, 0 newly installed, 5 to remove and 18 not upgraded.
After this operation, 78.0 MB disk space will be freed.
(Reading database ... 150299 files and directories currently installed.)
Removing mysql-server-core-5.7 (5.7.23-0ubuntu0.16.04.1) ...
Removing mysql-client-core-5.7 (5.7.23-0ubuntu0.16.04.1) ...
Removing libaio1:amd64 (0.3.110-2) ...
Removing libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) ...
Removing libnuma1:amd64 (2.0.11-1ubuntu1.1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
root@fileserver:~# sudo apt-get autoclean
Reading package lists... Done
Building dependency tree
Reading state information... Done
root@fileserver:~# rm -rf /etc/mysql
root@fileserver:~# sudo find / -iname 'mysql*' -exec rm -rf {} \;
find: '/var/lib/mysql-files': No such file or directory
find: '/var/lib/mysql-keyring': No such file or directory
root@fileserver:~#

Então eu não tinha certeza de que funcionava, pois havia alguns erros, tentei reinstalar o MySQL (é por isso que acho que o quebrei)

root@fileserver:~# sudo apt-get install mysql-client mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  mysql-client mysql-server
0 upgraded, 2 newly installed, 0 to remove and 18 not upgraded.
1 not fully installed or removed.
Need to get 0 B/20.9 kB of archives.
After this operation, 219 kB of additional disk space will be used.
Selecting previously unselected package mysql-client.
(Reading database ... 150436 files and directories currently installed.)
Preparing to unpack .../mysql-client_5.7.23-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-client (5.7.23-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.23-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-server (5.7.23-0ubuntu0.16.04.1) ...
Setting up mysql-server-5.7 (5.7.23-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
Setting up mysql-client (5.7.23-0ubuntu0.16.04.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)

Depois disso, tentei iniciar o MySQL

root@fileserver:~# sudo /etc/init.d/mysql start
[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
     failed!

Então eu olhei no journalctl -xe como recomendado e este é o log que eu sou mostrado

root@fileserver:~# journalctl -xe
-- The process /usr/share/mysql/mysql-systemd-start could not be executed and failed.
--
-- The error number returned by this process is 3.
Sep 30 06:35:38 fileserver systemd[1]: mysql.service: Control process exited, code=exited status=217
Sep 30 06:35:38 fileserver systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Sep 30 06:35:38 fileserver systemd[1]: mysql.service: Unit entered failed state.
Sep 30 06:35:38 fileserver systemd[1]: mysql.service: Failed with result 'exit-code'.
Sep 30 06:35:39 fileserver systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Sep 30 06:35:39 fileserver systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Sep 30 06:35:39 fileserver systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun starting up.
Sep 30 06:35:39 fileserver systemd[16248]: mysql.service: Failed at step USER spawning /usr/share/mysql/mysql-systemd-start: No such process
-- Subject: Process /usr/share/mysql/mysql-systemd-start could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /usr/share/mysql/mysql-systemd-start could not be executed and failed.
--
-- The error number returned by this process is 3.
Sep 30 06:35:39 fileserver systemd[1]: mysql.service: Control process exited, code=exited status=217
Sep 30 06:35:39 fileserver systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Sep 30 06:35:39 fileserver systemd[1]: mysql.service: Unit entered failed state.
Sep 30 06:35:39 fileserver systemd[1]: mysql.service: Failed with result 'exit-code'.
Sep 30 06:35:39 fileserver systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Sep 30 06:35:39 fileserver systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Sep 30 06:35:39 fileserver systemd[1]: mysql.service: Start request repeated too quickly.
Sep 30 06:35:39 fileserver systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.

root@fileserver:~# mysql --user=root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
root@fileserver:~# sudo apt-get install mysql-client mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  mysql-client mysql-server
0 upgraded, 2 newly installed, 0 to remove and 18 not upgraded.
1 not fully installed or removed.
Need to get 0 B/20.9 kB of archives.
After this operation, 219 kB of additional disk space will be used.
Selecting previously unselected package mysql-client.
(Reading database ... 150436 files and directories currently installed.)
Preparing to unpack .../mysql-client_5.7.23-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-client (5.7.23-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.23-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-server (5.7.23-0ubuntu0.16.04.1) ...
Setting up mysql-server-5.7 (5.7.23-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
Setting up mysql-client (5.7.23-0ubuntu0.16.04.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)
root@fileserver:~# ^C
root@fileserver:~# ^C
root@fileserver:~# service mysql start
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
root@fileserver:~# sudo /etc/init.d/mysql start
[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
 failed!
root@fileserver:~# ^C
root@fileserver:~# systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: exit-code) since Sun 2018-09-30 06:38:37 EDT; 25s ago
  Process: 16482 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=217/USER)
 Main PID: 15680 (code=exited, status=203/EXEC)

Sep 30 06:38:37 fileserver systemd[1]: Failed to start MySQL Community Server.
Sep 30 06:38:37 fileserver systemd[1]: mysql.service: Unit entered failed state.
Sep 30 06:38:37 fileserver systemd[1]: mysql.service: Failed with result 'exit-code'.
Sep 30 06:38:37 fileserver systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Sep 30 06:38:37 fileserver systemd[1]: Stopped MySQL Community Server.
Sep 30 06:38:37 fileserver systemd[1]: mysql.service: Start request repeated too quickly.
Sep 30 06:38:37 fileserver systemd[1]: Failed to start MySQL Community Server.
root@fileserver:~# ^C
root@fileserver:~# journalctl -xe
-- The process /usr/share/mysql/mysql-systemd-start could not be executed and failed.
--
-- The error number returned by this process is 3.
Sep 30 06:38:36 fileserver systemd[1]: mysql.service: Control process exited, code=exited status=217
Sep 30 06:38:36 fileserver systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Sep 30 06:38:36 fileserver systemd[1]: mysql.service: Unit entered failed state.
Sep 30 06:38:36 fileserver systemd[1]: mysql.service: Failed with result 'exit-code'.
Sep 30 06:38:37 fileserver systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Sep 30 06:38:37 fileserver systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Sep 30 06:38:37 fileserver systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun starting up.
Sep 30 06:38:37 fileserver systemd[16482]: mysql.service: Failed at step USER spawning /usr/share/mysql/mysql-systemd-start: No such process
-- Subject: Process /usr/share/mysql/mysql-systemd-start could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /usr/share/mysql/mysql-systemd-start could not be executed and failed.
--
-- The error number returned by this process is 3.
Sep 30 06:38:37 fileserver systemd[1]: mysql.service: Control process exited, code=exited status=217
Sep 30 06:38:37 fileserver systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Sep 30 06:38:37 fileserver systemd[1]: mysql.service: Unit entered failed state.
Sep 30 06:38:37 fileserver systemd[1]: mysql.service: Failed with result 'exit-code'.
Sep 30 06:38:37 fileserver systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Sep 30 06:38:37 fileserver systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Sep 30 06:38:37 fileserver systemd[1]: mysql.service: Start request repeated too quickly.
Sep 30 06:38:37 fileserver systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.

O mais estranho é que, mesmo depois de desinstalar completamente o MySQL, posso tentar fazer o login com mysql --user = root -p e posso digitar minha senha e obter o erro 2002. Certamente isso não deveria estar acontecendo se eu ter desinstalado completamente?

Qualquer ajuda seria apreciada, eu sou muito iniciante no que diz respeito a isso e não entendo completamente toda a saída dos logs.

Espero ter postado informações suficientes. Felicidades.

    
por Dan P 30.09.2018 / 12:54

2 respostas

2

Surely this shouldn't be happening if I have completely uninstalled it?

É evidente que você não o desinstalou completamente. Existem 2 partes para o mysql, o cliente e o servidor. Eles geralmente são instalados através de pacotes diferentes. O comando mysql é o programa do cliente. Ele é executado e solicita as informações que você disse para pedir. Em seguida, tenta fazer uma conexão usando parâmetros padrão para o servidor local. O servidor local não está em execução, portanto, você obtém um erro de 2002 ... não pode se conectar ao servidor ...

    
por 30.09.2018 / 14:11
0

Então eu não conheço o Ubuntu tão bem, mas há o seu erro ...

Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.23-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-server (5.7.23-0ubuntu0.16.04.1) ...
Setting up mysql-server-5.7 (5.7.23-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

Você pode tentar copiar o arquivo mysql.cnf padrão para esse local como uma correção rápida, mas você deve definitivamente tentar descobrir qual é esse erro / de onde ele vem ...

    
por 30.09.2018 / 17:29

Tags