MariaDB 10.1 server won't start after update
Today I ran apt-get upgrade
and there was an upgrade for MariaDB 10.1 ob Ubuntu Server 14.04 which failed:
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)
This is a nightmare, I can't access the database anymore. I have tried removing and purging it and installing again, but it just always ends with the same error.
According to /var/log/syslog
this has something to do with sockets and mysqld (after running 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!
Well, /var/run/mysqld/mysqld.sock
absolutely does exist. Also, I'm not sure why it says something about using /etc/mysql/debian.cnf
- my main mysql configuration file should actually be /etc/mysql/my.cnf
, no? I'm really out of ideas, any new ones would be appreciated!
Update (2015-12-11)
Still couldn't figure out what the problem is and the upgrade still won't work, still giving the same error. Like some of the (now deleted) answers said, the only solution was to roll back to an older snapshot of the server. Fortunately, saving the database was as easy as copying everything from /var/lib/mysql
over to the other snapshot.
I hope there is or will be a solution to this, because I couldn't find anything on Google that worked for me.
Here's how I solved my issue, I didn't have a backup of the server so I sort of "hard reset" MariaDB:
First, I backed up my /var/lib/mysql
folder: I'm assuming I have a /home/ubuntu
folder and copying the folder there.
cp -r /var/lib/mysql /home/ubuntu/
Secondly, I backed up my /etc/mysql
folder: I'm assuming I have a /home/ubuntu
folder and copy the folder there.
mkdir /home/ubuntu/etc_mysql
cp -r /etc/mysql /home/ubuntu/etc_mysql
Then I removed /var/lib/mysql
and /etc/mysql
folders
rm -rf /etc/mysql
rm -rf /var/lib/mysql
After that, I purged MariaDB:
apt-get purge mariadb-server mariadb-* mysql-*
apt-get autoremove
After purging, I re-installed mariadb-server
and re-configured it:
apt-get install mariadb-server
mysql_secure_installation
Copy whatever config you need from /home/ubuntu/etc_mysql
folder.
After that, I created my database and user from mysql
cli (or however you want)
Lastly, I copied my /home/ubuntu/mysql/**databaseName**
folder to /var/lib/mysql/**databaseName**
cp -r /home/ubuntu/mysql/databaseName /var/lib/mysql/
And then, I could access my data without loss, just as I'd left it.