结论

结论

结论

安装 mysql-server-5.7 失败

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

问题 1:如何解决下面描述的问题?

问题2:为什么会出现这种情况?

背景

我绞尽脑汁试图解决这个问题。今天早些时候,我在 Ubuntu VM 上启动了一个新的数据库实例,打算将 MYSQL 数据库文件保存在单独的驱动器上,将日志文件保存在第三个驱动器上。我在 Microsoft Azure 上启动了一个全新的 Ubuntu 16.04 LTM 虚拟机。然后我将 2 个磁盘连接到它,初始化它们的文件系统,并分别将它们安装到/mysql/log。接下来,我移动/var/log/log并替换/var/log为指向的符号链接/log

然后,当我尝试安装 mysql 服务器(使用默认值)时:

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

安装总是失败于Renaming removed key_buffer and myisam-recover options (if present)

我试过了:

  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. 所有 3 种解决方法 here 注意:解决方法 3 中途失败,因为sudo service mysql start失败了。

    mysql.service 的作业失败,因为控制进程退出并显示错误代码。有关详细信息,请参阅“systemctl status mysql.service”和“journalctl -xe”。

此外,我阅读并尝试了 Canonical 的几个帖子,但都无济于事,特别是,, 和.无论我尝试什么解决方法或修复,我总是在同一个地方出现同样的错误。

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)

通过阅读launchpad.net我知道去年这种情况比较常见,特别是因为更改了配置指令;但是,我正在一个新的虚拟机上安装它,因此没有改变任何配置无论如何,那里提出的每个解决方案,安装仍然会失败。我知道在安装后尝试配置 mysql-server 时会失败,但我不明白为什么它在这一点上不断失败。

Shell 输出

运行systemctl status mysql.service输出:

● 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

运行journalctl -xe输出 wall-o-text:

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.

运行sudo grep -Er 'key.buffer|myisam.recover' /etc/mysql输出:

/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

答案1

当你被 Ubuntu 16.04LTS 中的 mysql 安装错误困扰时该怎么办:

就我而言,问题是由缺少/etc/mysql/my.cnf.fallback 配置文件引起的。

可能的解决方法:

/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

/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

所以对我来说问题似乎是缺少文件/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/

因此,由于符号链接:

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

指向:

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

我猜想(祈祷)这/etc/mysql/mysql.cnf应该可以作为备选方案:

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

运行apt工具完成升级。

这对我有用。

初始错误报告: https://bugs.launchpad.net/bugs/1579708

标题:/etc/mysql如果文件在本地被删除, mysql 维护者脚本将失败

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

错误描述:

常见的报告是,在删除 /etc/mysql/ 中的文件后,与 MySQL 相关的维护脚本会失败。这是预期行为,因为政策是用户对 conf 文件(例如,/etc/mysql/ 中的文件)的修改应保留。

逻辑是,如果您修改了 /etc/mysql/,则假定这些修改是您想要的。打包无法为您修复任何损坏的自定义,因此例如如果您删除了这些文件,则打包将损坏。

在尝试修复此问题之前,请确保对您的系统进行完整备份,特别是任何数据库(默认情况下/var/lib/mysql),以防您的尝试导致数据被破坏。

要解决此问题,您可以尝试清除所有与 mysql 相关的软件包(特别是 mysql-common、mariadb-server-* 和/或 mysql-server-*)并重新安装它们。请注意,仅删除软件包是行不通的,因为 dpkg 将按照设计保留您对 /etc/mysql/ 的本地修改。

由于这种行为是设计使然,这不是 Ubuntu 中将要修复的错误,因此该错误的状态设置为无效以反映这一点。

相关内容