Não é possível instalar o mysql-server no Ubuntu 16.04

2

TLDR

Instalando o mysql-server-5.7 falha em

Renaming removed key_buffer and myisam-recover options (if present)

Pergunta 1: Como corrijo o problema descrito abaixo?

Pergunta 2: Por que isso ocorre?

Antecedentes

Estou no meu limite tentando resolver isso. Hoje cedo eu estava inicializando uma nova instância de banco de dados em uma VM Ubuntu com a intenção de executar manter os arquivos MYSQL em uma unidade separada e arquivos de log em uma terceira unidade. Eu inicializei uma nova máquina virtual Ubuntu 16.04 LTM no Microsoft Azure. Em seguida, anexei dois discos a ele, inicializei seus sistemas de arquivos e os instalei em /mysql e /log , respectivamente. Em seguida, movi /var/log para /log e substituí /var/log por um link simbólico apontando para /log .

Então, quando eu tentei instalar o servidor mysql (usando padrões):

sudo apt-get mysql-server
sudo apt-get mysql-server-5.7

A instalação sempre falha em Renaming removed key_buffer and myisam-recover options (if present) .

Eu tentei:

  1. sudo dpkg-reconfigure mysql-server-5.1 ,
  2. sudo apt-get purge mysql-common mysql-server-5.1 ,
  3. sudo rm /etc/mysql/my.cnf /etc/mysql/my.cnf.fallback /etc/mysql/my.cnf.migrated my.cnf.wba.bak /etc/alternatives/my.cnf ,
  4. sudo systemctl enable mysql.service
  5. sudo apt-get remove --purge mysql*
  6. sudo update-alternatives --remove my.cnf /etc/mysql/my.cnf.migrated
  7. Todas as 3 soluções alternativas here Nota: a solução 3 falha na metade porque sudo service mysql start falha.

    Job para mysql.service falhou porque o processo de controle foi encerrado com o código de erro. Veja "systemctl status mysql.service" e "journalctl -xe" para detalhes.

Além disso, eu li e tentei vários dos tópicos da Canonical sem sucesso, particularmente, e this . Seja qual for a solução ou correção que eu tentei, sempre recebo o mesmo erro no mesmo lugar.

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-cloud-tools-4.4.0-81 linux-cloud-tools-4.4.0-81-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7
Suggested packages:
  mailx tinyca
The following NEW packages will be installed:
  mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server mysql-server-5.7 mysql-server-core-5.7
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/18.2 MB of archives.
After this operation, 160 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 94155 files and directories currently installed.)
Preparing to unpack .../mysql-common_5.7.18-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-common (5.7.18-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-client-core-5.7.
Preparing to unpack .../mysql-client-core-5.7_5.7.18-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.18-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.18-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.18-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server-core-5.7.
Preparing to unpack .../mysql-server-core-5.7_5.7.18-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.18-0ubuntu0.16.04.1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up mysql-common (5.7.18-0ubuntu0.16.04.1) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mysql-server-5.7.
(Reading database ... 94311 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.18-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.18-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.18-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-server (5.7.18-0ubuntu0.16.04.1) ...
Processing triggers for systemd (229-4ubuntu17) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up mysql-client-core-5.7 (5.7.18-0ubuntu0.16.04.1) ...
Setting up mysql-client-5.7 (5.7.18-0ubuntu0.16.04.1) ...
Setting up mysql-server-core-5.7 (5.7.18-0ubuntu0.16.04.1) ...
Setting up mysql-server-5.7 (5.7.18-0ubuntu0.16.04.1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Fri 2017-06-30 22:14:16 UTC; 30ms ago
  Process: 8314 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 8312 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 8304 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 8312 (code=exited, status=1/FAILURE)

Jun 30 22:14:16 PMCTMYSQLWEBDEV systemd[1]: Failed to start MySQL Community Server.
Jun 30 22:14:16 PMCTMYSQLWEBDEV systemd[1]: mysql.service: Unit entered failed state.
Jun 30 22:14:16 PMCTMYSQLWEBDEV systemd[1]: mysql.service: Failed with result 'exit-code'.
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
Processing triggers for systemd (229-4ubuntu17) ...
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

A partir da leitura de um tópico extenso em launchpad.net , eu sei que essa foi uma ocorrência relativamente comum no ano passado, particularmente devido a uma diretiva de configuração alterada ; no entanto, estou instalando isso em uma VM nova, portanto nenhuma configuração foi alterada . De qualquer maneira, toda solução proposta lá, a instalação ainda falha. Eu entendo que está falhando ao tentar configurar o mysql-server após a instalação, mas eu não entendo porque ele continua falhando neste momento.

Saídas da Shell

Executando systemctl status mysql.service de saídas:

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) (Result: exit-code) since Fri 2017-06-30 23:02:31 UTC; 28s ago
  Process: 18500 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 18491 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 18500 (code=exited, status=1/FAILURE);         : 18501 (mysql-systemd-s)
    Tasks: 2
   Memory: 312.0K
      CPU: 563ms
   CGroup: /system.slice/mysql.service
           └─control
             ├─18501 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─18571 sleep 1

A execução de journalctl -xe gera uma mensagem de texto:

Jun 30 23:03:33 MYVMSERVERNAME kernel: audit: type=1400 audit(1498863813.150:4573): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/log
Jun 30 23:03:33 MYVMSERVERNAME kernel: audit: type=1400 audit(1498863813.150:4574): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/log
Jun 30 23:03:33 MYVMSERVERNAME systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Jun 30 23:03:36 MYVMSERVERNAME systemd[1]: Time has been changed
-- Subject: Time change
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The system clock has been changed to REALTIME microseconds after January 1st, 1970.
Jun 30 23:03:36 MYVMSERVERNAME systemd[1]: snapd.refresh.timer: Adding 51min 45.765270s random time.
Jun 30 23:03:36 MYVMSERVERNAME systemd[1]: apt-daily.timer: Adding 9h 36min 3.316616s random time.
Jun 30 23:03:36 MYVMSERVERNAME systemd[4309]: Time has been changed
-- Subject: Time change
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The system clock has been changed to REALTIME microseconds after January 1st, 1970.
Jun 30 23:03:41 MYVMSERVERNAME systemd[4309]: Time has been changed
-- Subject: Time change
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The system clock has been changed to REALTIME microseconds after January 1st, 1970.
Jun 30 23:03:41 MYVMSERVERNAME systemd[1]: Time has been changed
-- Subject: Time change
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The system clock has been changed to REALTIME microseconds after January 1st, 1970.
Jun 30 23:03:41 MYVMSERVERNAME systemd[1]: snapd.refresh.timer: Adding 28min 53.776594s random time.
Jun 30 23:03:41 MYVMSERVERNAME systemd[1]: apt-daily.timer: Adding 2h 8min 50.808503s random time.
Jun 30 23:03:46 MYVMSERVERNAME systemd[1]: Time has been changed
-- Subject: Time change
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The system clock has been changed to REALTIME microseconds after January 1st, 1970.
Jun 30 23:03:46 MYVMSERVERNAME systemd[1]: snapd.refresh.timer: Adding 5h 21min 26.938184s random time.
Jun 30 23:03:46 MYVMSERVERNAME systemd[1]: apt-daily.timer: Adding 10h 8min 22.523179s random time.
Jun 30 23:03:46 MYVMSERVERNAME systemd[4309]: Time has been changed
-- Subject: Time change
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The system clock has been changed to REALTIME microseconds after January 1st, 1970.
Jun 30 23:03:51 MYVMSERVERNAME systemd[4309]: Time has been changed
-- Subject: Time change
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The system clock has been changed to REALTIME microseconds after January 1st, 1970.
Jun 30 23:03:51 MYVMSERVERNAME systemd[1]: Time has been changed
-- Subject: Time change
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The system clock has been changed to REALTIME microseconds after January 1st, 1970.
Jun 30 23:03:51 MYVMSERVERNAME systemd[1]: snapd.refresh.timer: Adding 1h 36min 20.966420s random time.
Jun 30 23:03:51 MYVMSERVERNAME systemd[1]: apt-daily.timer: Adding 2h 46min 45.417443s random time.

Executando sudo grep -Er 'key.buffer|myisam.recover' /etc/mysql de saídas:

/etc/mysql/mysql.conf.d/mysqld.cnf:key_buffer_size              = 16M
/etc/mysql/mysql.conf.d/mysqld.cnf:myisam-recover-options  = BACKUP

/etc/mysql/my.cnf

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

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

/etc/mysql/mysql.conf.d/mysqld.cnf

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

[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
nice            = 0

[mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size         = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options  = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit       = 1M
query_cache_size        = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#log_slow_queries       = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id              = 1
#log_bin                        = /var/log/mysql/mysql-bin.log
expire_logs_days        = 10
max_binlog_size   = 100M
#binlog_do_db           = include_database_name
#binlog_ignore_db       = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
    
por KareemElashmawy 01.07.2017 / 01:30

1 resposta

0

O que fazer quando você é atingido pelo bug de instalação do mysql no Ubuntu 16.04LTS:

No meu caso, o problema foi desencadeado por um /etc/mysql/my.cnf.fallback ausente arquivo de configuração.

Solução alternativa possível:

Em /var/log/apt/history.log

Start-Date: 2017-01-20 10:42:27
Commandline: aptdaemon role='role-commit-packages' sender=':1.126'
Upgrade: mysql-server-5.7:amd64 (5.7.16-0ubuntu0.16.04.1, 5.7.17-0ubuntu0.16.04.1), mysql-server:amd64 (5.7.16-0ubuntu0.16.04.1, 5.7.17-0ubuntu0.16.04.1), mysql-client:amd64 (5.7.16-0ubuntu0.16.04.1, 5.7.17-0ubuntu0.16.04.1), libmysqlclient20:amd64 (5.7.16-0ubuntu0.16.04.1, 5.7.17-0ubuntu0.16.04.1), libmysqlclient20:i386 (5.7.16-0ubuntu0.16.04.1, 5.7.17-0ubuntu0.16.04.1), mysql-server-core-5.7:amd64 (5.7.16-0ubuntu0.16.04.1, 5.7.17-0ubuntu0.16.04.1)
Error: Sub-process /usr/bin/dpkg returned an error code (1)
End-Date: 2017-01-20 10:42:27

Em /var/log/apt/term.log

Log started: 2017-01-20 10:42:27
Setting up mysql-common (5.7.17-0ubuntu0.16.04.1) ...
update-alternatives: error: alternative path /etc/mysql/my.cnf.fallback doesn't exist
dpkg: error processing package mysql-common (--configure):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 mysql-common
Log ended: 2017-01-20 10:42:27

Então, o problema para mim parece ser a falta do arquivo /etc/mysql/my.cnf.fallback .

ll /etc/myql
drwxr-xr-x 4 root root 4096 gen 20 10:59 ./
drwxr-xr-x 189 root root 12288 gen 19 12:44 ../
drwxr-xr-x 2 root root 4096 gen 20 09:43 conf.d/
-rw------- 1 root root 317 nov 19 10:57 debian.cnf
-rwxr-xr-x 1 root root 120 ott 24 17:13 debian-start*
lrwxrwxrwx 1 root root 24 nov 18 21:12 my.cnf -> /etc/alternatives/my.cnf
-rw-r--r-- 1 root root 3028 nov 18 21:27 my.cnf.migrated
-rw-r--r-- 1 root root 682 lug 11 2016 mysql.cnf
drwxr-xr-x 2 root root 4096 nov 18 22:24 mysql.conf.d/

Então, porque o symlink:

my.cnf -> /etc/alternatives/my.cnf

aponta de volta para:

/etc/alternatives/my.cnf -> /etc/mysql/mysql.cnf

eu assumi (cruzando meus dedos) que /etc/mysql/mysql.cnf deveria ser elegíveis como substituto alternativo:

sudo cp /etc/mysql/mysql.cnf /etc/mysql/my.cnf.fallback

Execute a ferramenta apt para concluir a atualização.

Isso funcionou para mim.

Relatório inicial de erros: link

Título:   Scripts do mantenedor mysql falham se arquivos em /etc/mysql foram deletados   localmente

Status in mysql-5.5 package in Ubuntu:
  Invalid
Status in mysql-5.6 package in Ubuntu:
  Invalid
Status in mysql-5.7 package in Ubuntu:
  Invalid

Descrição do bug:

Um relatório comum é que os scripts do mantenedor relacionados ao MySQL falharam depois que os arquivos em / etc / mysql / foram deletados. Esse é o comportamento esperado, pois a política é que as modificações dos arquivos conf (por exemplo, arquivos em / etc / mysql /) dos usuários devem ser preservadas.

A lógica é que se você modificou o / etc / mysql /, presume-se que essas modificações são o que você deseja. A embalagem não pode corrigir nenhuma personalização quebrada para você, portanto, por exemplo, se você tiver excluído esses arquivos, o empacotamento será quebrado.

Antes de tentar consertar isso, certifique-se de fazer um backup completo do seu sistema e, em particular, de quaisquer bancos de dados (por padrão, em /var/lib/mysql ), caso sua tentativa resulte na destruição de seus dados.

Para corrigir esta situação, você pode tentar limpar todos os pacotes relacionados ao mysql (particularmente mysql-common, mariadb-server- * e / ou mysql-server- *) e reinstalá-los. Note que apenas removendo os pacotes   não funcionará, já que o dpkg irá preservar suas modificações locais em / etc / mysql / como projetado.

Como esse comportamento é por design, isso não é um bug no Ubuntu que será corrigido e, portanto, o status desse bug é definido como Invalid para refletir isso.

    
por 01.07.2017 / 02:34