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:

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.

  • Did you reboot system after upgrade ?
    – KK Patel
    Nov 27, 2015 at 13:24

1 Answer 1


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

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.

  • Thank you very much for sharing this! Sounds promising, even though as far as I remember I did all the purge and remove stuff, but yeah, I never completeley deleted /var/lib/mysql, so maybe that could be the key. I can't work on the server right now, but I'll try it as soon as I get the chance to.
    – Quasdunk
    Dec 12, 2015 at 15:19
  • 1
    Today I have tried your solution and it worked! Well, sort of... After reinstalling MariaDB it worked at first, but after copying the backed up files to /var/lib/mysql the server failed to start again. In particular, the mysql-table seems to cause this issue, but I couldn't figure out why. All other tables (InnoDb and MyIsam) didn't cause any problems. I'll keep trying, so thank you, this brings me actually a big step closer to the solution :) I'm accepting this answer, because it actually answers my initial question.
    – Quasdunk
    Dec 19, 2015 at 9:46
  • 1
    One quick note though: I had to replace mariadb* mysql* with mariadb-* mysql-* in the apt-get purge command because otherwise it would give me a dependency error (can't remember which one it was). And also I had to restart the server after that.
    – Quasdunk
    Dec 19, 2015 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.