MariaDB 10.1 服务器更新后无法启动

MariaDB 10.1 服务器更新后无法启动

今天我运行了apt-get upgradeMariaDB 10.1 ob Ubuntu Server 14.04 的升级,但升级失败了:

Setting up libmysqlclient18 (10.1.9+maria-1~trusty) ...
Setting up libmariadbclient18 (10.1.9+maria-1~trusty) ...
Setting up mariadb-client-core-10.1 (10.1.9+maria-1~trusty) ...
Setting up mariadb-client-10.1 (10.1.9+maria-1~trusty) ...
Setting up mariadb-server-core-10.1 (10.1.9+maria-1~trusty) ...
Setting up mariadb-server-10.1 (10.1.9+maria-1~trusty) ...
Installing new version of config file /etc/init.d/mysql ...

 * Stopping MariaDB database server mysqld [ OK ] 
 * Starting MariaDB database server mysqld [fail] 

invoke-rc.d: initscript mysql, action "start" failed.

dpkg: error processing package mariadb-server-10.1 (--configure):
 subprocess installed post-installation script returned error exit status 1

dpkg: dependency problems prevent configuration of mariadb-server:
 mariadb-server depends on mariadb-server-10.1 (= 10.1.9+maria-1~trusty); however:

  Package mariadb-server-10.1 is not configured yet.

dpkg: error processing package mariadb-server (--configure):
 dependency problems - leaving unconfigured
Processing triggers for ureadahead (0.100.0-16) ...
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
No apport report written because the error message indicates its a followup error from a previous failure. 

Errors were encountered while processing:

 mariadb-server-10.1
 mariadb-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

这简直是​​一场噩梦,我再也无法访问数据库了。我尝试过删除并清除数据库,然后重新安装,但总是出现相同的错误。

据此/var/log/syslog与套接字和 mysqld 有关(运行后service mysql restart):

mysqld: 151127 11:51:07 [ERROR] mysqld got signal 11 ;

...

mysqld_safe: mysqld from pid file /var/run/mysqld/mysqld.pid ended
/etc/init.d/mysql[14132]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
/etc/init.d/mysql[14132]: #007/usr/bin/mysqladmin: connect to server at 'localhost' failed
/etc/init.d/mysql[14132]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111 "Connection refused")'
/etc/init.d/mysql[14132]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

嗯,/var/run/mysqld/mysqld.sock确实存在。另外,我不确定为什么它提到使用/etc/mysql/debian.cnf- 我的主要 mysql 配置文件实际上应该是/etc/mysql/my.cnf,不是吗?我真的没有主意了,任何新的想法都会很感激!


更新(2015-12-11)

仍然不知道问题是什么,升级仍然无效,仍然给出相同的错误。就像一些(现已删除)答案所说的那样,唯一的解决方案是回滚到服务器的旧快照。幸运的是,保存数据库就像将所有内容复制/var/lib/mysql到另一个快照一样简单。

我希望有或者将会有解决这个问题的方法,因为我在 Google 上找不到适合我的东西。

答案1

以下是我解决问题的方法,我没有服务器的备份,因此我对 MariaDB 进行了“硬重置”:

首先,我备份了我的/var/lib/mysql文件夹:我假设我有一个/home/ubuntu文件夹并将该文件夹复制到那里。

cp -r /var/lib/mysql /home/ubuntu/

其次,我备份了我的/etc/mysql文件夹:我假设我有一个/home/ubuntu文件夹并将该文件夹复制到那里。

mkdir /home/ubuntu/etc_mysql
cp -r /etc/mysql /home/ubuntu/etc_mysql

然后我删除了/var/lib/mysql/etc/mysql文件夹

rm -rf /etc/mysql
rm -rf /var/lib/mysql

之后,我清除了 MariaDB:

apt-get purge mariadb-server mariadb-* mysql-*
apt-get autoremove

清除后,我重新安装mariadb-server并重新配置它:

apt-get install mariadb-server
mysql_secure_installation

从文件夹复制您需要的任何配置/home/ubuntu/etc_mysql

之后,我从mysqlcli 创建了数据库和用户(或者你想要的)

最后,我将/home/ubuntu/mysql/**databaseName**文件夹复制到/var/lib/mysql/**databaseName**

cp -r /home/ubuntu/mysql/databaseName /var/lib/mysql/

然后,我就可以访问我的数据而不会造成任何丢失,就像我离开时一样。

相关内容