Can't connect to DB after Upgrade to 10.3.2

Steps to reproduce

  1. Download the latest owncloud version via apt-get in command line.
  2. Upgrade through the web interface of the owncloud server.

Expected behaviour

Showing the login page after upgrade

Actual behaviour

Instead I got the following message:

Exception occurred while logging exception: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory
#0 /var/www/owncloud/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
#1 /var/www/owncloud/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /var/www/owncloud/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /var/www/owncloud/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /var/www/owncloud/lib/private/DB/Connection.php(144): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /var/www/owncloud/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#6 /var/www/owncloud/lib/private/DB/ConnectionFactory.php(145): Doctrine\DBAL\DriverManager::getConnection(Array, Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#7 /var/www/owncloud/lib/private/Server.php(532): OC\DB\ConnectionFactory->getConnection('mysql', Array)
#8 /var/www/owncloud/lib/composer/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#9 /var/www/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(108): Pimple\Container->offsetGet('DatabaseConnect...')
#10 /var/www/owncloud/lib/private/ServerContainer.php(86): OC\AppFramework\Utility\SimpleContainer->query('DatabaseConnect...')
#11 /var/www/owncloud/lib/private/Server.php(1220): OC\ServerContainer->query('DatabaseConnect...')
#12 /var/www/owncloud/lib/private/Server.php(250): OC\Server->getDatabaseConnection()
#13 /var/www/owncloud/lib/composer/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#14 /var/www/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(108): Pimple\Container->offsetGet('AccountMapper')
#15 /var/www/owncloud/lib/private/ServerContainer.php(86): OC\AppFramework\Utility\SimpleContainer->query('AccountMapper')
#16 /var/www/owncloud/lib/private/Server.php(1066): OC\ServerContainer->query('AccountMapper')
#17 /var/www/owncloud/lib/private/Server.php(256): OC\Server->getAccountMapper()
#18 /var/www/owncloud/lib/composer/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#19 /var/www/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(108): Pimple\Container->offsetGet('UserManager')
#20 /var/www/owncloud/lib/private/ServerContainer.php(86): OC\AppFramework\Utility\SimpleContainer->query('UserManager')
#21 /var/www/owncloud/lib/private/Server.php(1059): OC\ServerContainer->query('UserManager')
#22 /var/www/owncloud/lib/private/Server.php(316): OC\Server->getUserManager()
#23 /var/www/owncloud/lib/composer/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#24 /var/www/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(108): Pimple\Container->offsetGet('UserSession')
#25 /var/www/owncloud/lib/private/ServerContainer.php(86): OC\AppFramework\Utility\SimpleContainer->query('UserSession')
#26 /var/www/owncloud/lib/private/Server.php(1083): OC\ServerContainer->query('UserSession')
#27 /var/www/owncloud/lib/private/Log.php(436): OC\Server->getUserSession()
#28 /var/www/owncloud/lib/public/Util.php(169): OC\Log->logException(Array, Array)
#29 /var/www/owncloud/lib/base.php(435): OCP\Util::logException('base', Object(Doctrine\DBAL\DBALException))
#30 /var/www/owncloud/lib/base.php(587): OC::initSession()
#31 /var/www/owncloud/lib/base.php(1005): OC::init()
#32 /var/www/owncloud/index.php(53): require_once('/var/www/ownclo...')
#33 {main}

Server configuration

  • Operating system: Raspbian/Debian 9.11 Stretch

  • Web server: Apache/2.4.25 (Raspbian)

  • Database: mysql Ver 15.1 Distrib 10.1.38-MariaDB, for debian-linux-gnueabihf (armv7l) using readline 5.2

  • PHP version: PHP 7.0.33-0+deb9u6 (cli) (built: Oct 24 2019 18:50:20) ( NTS )

  • ownCloud version: ownCloud Core [10.3.2] (2019-12-04)

  • Updated from an older ownCloud or fresh install: updated from earlier version

It looks to me like a permissions issue…!?

When I try to restart mysql with sudo service mysql restart, I get:

Job for mariadb.service failed because a fatal signal was delivered to the control process.
See “systemctl status mariadb.service” and “journalctl -xe” for details.

journalctl -xe brings me:

– Unit mariadb.service has begun starting up.

Dec 18 07:36:37 raspcloud mysqld[25529]: 2019-12-18 7:36:37 1996169008 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as

Dec 18 07:36:38 raspcloud systemd[1]: mariadb.service: Main process exited, code=killed, status=6/ABRT

Dec 18 07:36:38 raspcloud systemd[1]: Failed to start MariaDB 10.1.38 database server.

– Subject: Unit mariadb.service has failed

– Defined-By: systemd

– Support: […]

– Unit mariadb.service has failed.

– The result is failed.

Dec 18 07:36:38 raspcloud systemd[1]: mariadb.service: Unit entered failed state.

Dec 18 07:36:38 raspcloud systemd[1]: mariadb.service: Failed with result ‘signal’.

Dec 18 07:36:43 raspcloud systemd[1]: mariadb.service: Service hold-off time over, scheduling restart.

Dec 18 07:36:43 raspcloud systemd[1]: Stopped MariaDB 10.1.38 database server.

– Subject: Unit mariadb.service has finished shutting down

– Defined-By: systemd

– Support: […]

– Unit mariadb.service has finished shutting down.

Any ideas how to fix this?
Thank you very much!

First this is not a problem originating in ownCloud, this is very clearly a problem with mariadb.

So do what you would do for any failing service:

  1. Check the logs
  2. Find the error message
  3. Chuck into your favourite search engine

For mysql/mariadb there are a few steps you can do before:

  • How much free disk do you have
  • Run a check and repair for all tables
  • If there isn’t too much data loss, restore a backup

Unfortunately I’m not a very good DBA, so I’m not sure if this is good advice and I’m also not entirely sure how exactly you would do that:

  • You can try starting the DB without databases and try to import the data back in

:crossed_fingers: you can get it back up and running

1 Like

Thanks for your reply. Now that the christmas / new year - madness is over (happy both of them btw) I finally found the time to get back to this issue…

You are right, this clearly was a database-problem.
In /var/log/mysql/error.log I got this error-message on bootup:
[ERROR] InnoDB: Database page corruption on disk or a failed file read of tablespace ./ibdata1 page [page id: space=0, page number=32824]. You may have to recover from a backup.

So here is what I did to rescue the data, just in case someone runs into the same problems.
Attention: I’m a complete noob and I cannot guarantee that any of this works for you. All I know is it worked for me without any loss of data. All directories might differ, depending on your installation/configuration (see opening post for mine).

#check what’s going on in a separate window all the time
tail -f /var/log/mysql/error.log

#stop mysql service (if running)
/etc/init.d/mysql stop

mkdir /var/lib/bu_innodb_data
cp /var/lib/mysql/ib* /var/lib/bu_innodb_data

#edit server config
nano /etc/mysql/mariadb.conf.d/50-server.cnf
put the line ‘innodb_force_recovery=1’ below [mysqld]
(start with 1 and go up to 4 until you can start the mysql-service)

#start mysql service
/etc/init.d/mysql start

#export databases
mysqldump -uroot -pPASSWORD --port 3306 -h --all-databases > all_my_databases.sql

#stop mysql service
/etc/init.d/mysql stop

#delete old databases
mkdir /var/lib/old_innodb_data
mv /var/lib/mysql/ib* /var/lib/old_innodb_data

#remove entry from .cnf
nano /etc/mysql/mariadb.conf.d/50-server.cnf

#start mysql service
/etc/init.d/mysql start

#log into mysql shell
mysql -uroot -pPASSWORT

#delete singles databases

#remove the folder in terminal
mv /var/lib/mysql/xyz ~/xyz

#restart mysql service
/etc/init.d/mysql restart

#Zurückspielen der DB
mysql -uroot -pPASSWORD --port 3306 -h < all_my_databases1.sql

#Kontrolle ob alles geklappt hat
mysqlcheck -uroot -pPASSWORD --all-databases --repair

#Neustart Mysql
/etc/init.d/mysql restart