Renaming removed key_buffer and myisam-recover options (if present)
我试图解决这个问题。 今天早些时候,我正在Ubuntu VM上启动一个新的数据库实例,目的是将MYSQL数据库文件保存在一个单独的驱动器上,并在第三个驱动器上logging日志文件。 我在Microsoft Azure上启动了一个新的Ubuntu 16.04 LTM虚拟机。 然后,我附加了2个磁盘,初始化他们的文件系统,并分别挂载到/mysql和/log 。 接下来,我将/var/log移动到/log并用指向/log的符号链接replace了/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)安装始终失败。
我试过了:
sudo dpkg-reconfigure mysql-server-5.1 , sudo apt-get purge mysql-common mysql-server-5.1 , sudo rm /etc/mysql/my.cnf /etc/mysql/my.cnf.fallback /etc/mysql/my.cnf.migrated my.cnf.wba.bak /etc/alternatives/my.cnf , sudo systemctl enable mysql.service sudo apt-get remove --purge mysql* sudo update-alternatives --remove my.cnf /etc/mysql/my.cnf.migrated here所有3个解决方法注意:解决方法3中途通过,因为sudo service mysql start失败。
作业mysql.service失败,因为控制进程退出错误代码。 有关详细信息,请参阅“systemctl status mysql.service”和“journalctl -xe”。
此外,我阅读并尝试了几个典型的线程无济于事,特别是这个 , 这个 。 无论我尝试什么解决方法或修复,我总是在同一个地方得到同样的错误。
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上的一个广泛的线程,我知道这是去年比较常见的事件,特别是由于改变了configuration指令 ; 但是,我正在安装这个新的虚拟机,因此没有configuration被改变 。 无论哪种方式,在那里提出的每个解决scheme,安装仍然失败。 我知道在安装之后尝试configurationmysql-server时失败了,但是我不明白为什么在这个时候会失败。
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
# # 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/
# # 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
在我的情况下,这个问题是由缺less/etc/mysql/my.cnf.fallbackconfiguration文件触发的。
可能的解决方法:
在/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
所以对我来说这个问题似乎是缺less/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 /按devise。
由于这种行为是由devise,这不是在Ubuntu中的错误将被修复,所以这个错误的状态被设置为无效,以反映这一点。