MySql 更新后崩溃

MySql 更新后崩溃

我有一个最新的 Ubuntu 16.04 桌面。我今天安装了例行更新,其中包括 MySQL 更新。Mysql 现在坏了。

我遵循了以下步骤: 16.04 升级导致 mysql-server 崩溃 但现在我得到:service mysql start mysql.service 的作业失败,因为控制进程退出并显示错误代码。有关详细信息,请参阅“systemctl status mysql.service”和“journalctl -xe”。

root@civet:~# systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
   Active: inactive (dead) (Result: exit-code) since Sat 2017-01-21 16:03:52 EST
  Process: 32687 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=e
  Process: 32686 ExecStart=/usr/sbin/mysqld (code=exited, status=0/SUCCESS)
  Process: 15576 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exi
 Main PID: 32686 (code=exited, status=0/SUCCESS)

Jan 21 16:03:52 civet systemd[1]: Failed to start MySQL Community Server.
Jan 21 16:03:52 civet systemd[1]: mysql.service: Unit entered failed state.
Jan 21 16:03:52 civet systemd[1]: mysql.service: Failed with result 'exit-code'.
Jan 21 16:03:52 civet systemd[1]: mysql.service: Service hold-off time over, sch
Jan 21 16:03:52 civet systemd[1]: Stopped MySQL Community Server.
Jan 21 16:03:52 civet systemd[1]: mysql.service: Start request repeated too quic
Jan 21 16:03:52 civet systemd[1]: Failed to start MySQL Community Server.
root@civet:~# service mysql stop
root@civet:~# 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@civet:~# journalctl -xe
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysql.service has failed.
-- 
-- The result is failed.
Jan 21 16:06:09 civet systemd[1]: mysql.service: Unit entered failed state.
Jan 21 16:06:09 civet systemd[1]: mysql.service: Failed with result 'exit-code'.
Jan 21 16:06:09 civet systemd[1]: mysql.service: Service hold-off time over, sch
Jan 21 16:06:09 civet 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.
Jan 21 16:06:09 civet systemd[1]: mysql.service: Start request repeated too quic
Jan 21 16:06:09 civet 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.

有什么建议吗?如果能帮助我将不胜感激。


谢谢。一段时间以来,我一直在使用 mysqldump 进行每日备份。一旦 mysql 再次启动并运行,我就会使用 automysqlbackup。我运行了 remove --purge 命令,然后是 install,这就是我得到的结果(这种情况整天都在发生)

Renaming removed key_buffer and myisam-recover options (if present)
mysql_upgrade: Got error: 1524: Plugin 'mysql_old_password' is not loaded while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          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-4ubuntu16) ...
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)

我似乎只是在原地打转。另外,old_password 解决方法不再有效,所以我尝试设置 GLOBAL old_passwords=0;

如果我尝试连接到 mysql,我会得到:错误 2002 (HY000):无法通过套接字“/var/run/mysqld/mysqld.sock”连接到本地 MySQL 服务器 (2) 我已在 my.cnf 中将套接字设置为该路径

答案1

我建议备份,然后清除并重新安装 mysql-server。

您可以安装 automysqlbackup 吗?

sudo apt-get install automysqlbackup

然后从命令行运行 automysqlbackup,并备份 /etc 目录:

sudo /usr/sbin/automysqlbackup

sudo rsync -av /etc/ $HOME/etc-backup/

检查 automysqlbackup 是否成功创建备份:

sudo ls -la /var/lib/automysqlbackup/daily/

之后删除 mysql 服务器包,清除配置,并重新安装 mysql-server:

sudo apt-get remove --purge mysql-server*

sudo apt-get install mysql-server

将 mysqldump 放回去,通过从提到的 automysqlbackup “daily” 目录复制,解压缩文件,然后:

sudo mysql --defaults-file=/etc/mysql/debian.cnf

mysql> create database example-db;
mysql> quit

sudo mysql -u root -p example-db < example-db-daily.sql

对所有数据库执行相同操作。

答案2

通过重新安装 mysql(两次)解决了问题。但是 MySQL Workbench 现在无法连接,并出现错误:

错误弹出

相关内容