Problems with MySQL (MariaDB) connection


#1

Actual behaviour
Internal Server Error. OwnCloud is not working.

Server configuration
Operating system: Cent OS 7.1
Web server: Apache 2
Database: MariaDB
PHP version: 5.4.16
ownCloud version (see ownCloud admin page): 9.0.3
ownCloud log (data/owncloud.log):
Can't connect to local MySQL server through socket '\\/var\\/lib\\/mysql\\/mysql.sock' (13)\",\"Code\":0,\"Trace\":\"#0 \\/var\\/www\\/html\\/owncloud\\/3rdparty\\/doctrine\\/dbal\\/lib\\/Doctrine\\/DBAL\\/Connection.php(429): OC\\DB\\Connection->connect()\n#1 \\/var\\/www\\/html\\/owncloud\\/3rdparty\\/doctrine\\/dbal\\/lib\\/Doctrine\\/DBAL\\/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 \\/var\\/www\\/html\\/owncloud\\/3rdparty\\/doctrine\\/dbal\\/lib\\/Doctrine\\/DBAL\\/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 \\/var\\/www\\/html\\/owncloud\\/3rdparty\\/doctrine\\/dbal\\/lib\\/Doctrine\\/DBAL\\/Connection.php(621): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/db\\/connection.php(137): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 \\/var\\/www\\/html\\/owncloud\\/3rdparty\\/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))\n#6 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/db\\/connectionfactory.php(118): Doctrine\\DBAL\\DriverManager::getConnection(Array, Object(Doctrine\\DBAL\\Configuration), Object(Doctrine\\Common\\EventManager))\n#7 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/server.php(366): OC\\DB\\ConnectionFactory->getConnection('mysql', Array)\n#8 \\/var\\/www\\/html\\/owncloud\\/3rdparty\\/pimple\\/pimple\\/src\\/Pimple\\/Container.php(113): OC\\Server->OC\\{closure}(Object(OC\\Server))\n#9 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/appframework\\/utility\\/simplecontainer.php(102): Pimple\\Container->offsetGet('DatabaseConnect...')\n#10 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/servercontainer.php(87): OC\\AppFramework\\Utility\\SimpleContainer->query('DatabaseConnect...')\n#11 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/server.php(886): OC\\ServerContainer->query('DatabaseConnect...')\n#12 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/server.php(260): OC\\Server->getDatabaseConnection()\n#13 \\/var\\/www\\/html\\/owncloud\\/3rdparty\\/pimple\\/pimple\\/src\\/Pimple\\/Container.php(113): OC\\Server->OC\\{closure}(Object(OC\\Server))\n#14 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/appframework\\/utility\\/simplecontainer.php(102): Pimple\\Container->offsetGet('AppConfig')\n#15 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/servercontainer.php(87): OC\\AppFramework\\Utility\\SimpleContainer->query('AppConfig')\n#16 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/server.php(825): OC\\ServerContainer->query('AppConfig')\n#17 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/util.php(424): OC\\Server->getAppConfig()\n#18 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/util.php(357): OC_Util::loadVersion()\n#19 \\/var\\/www\\/html\\/owncloud\\/lib\\/public\\/util.php(72): OC_Util::getVersion()\n#20 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/defaults.php(52): OCP\\Util::getVersion()\n#21 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/template.php(79): OC_Defaults->construct()\n#22 \\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/template.php(339): OC_Template->_construct('', 'exception', 'error', false)\n#23 \\/var\\/www\\/html\\/owncloud\\/index.php(55): OCTemplate::printExceptionErrorPage(Object(Doctrine\\DBAL\\DBALException))\n#24 {main}\",\"File\":\"\\/var\\/www\\/html\\/owncloud\\/lib\\/private\\/db\\/connection.php\",\"Line\":54}","level":3,"time":"2016-07-20T17:24:29+00:00","method":"GET","url":"\/","user":"--"}
{"reqId":"V4@z3G@rmiaZU3NaMOHeXQAAAAA","remoteAddr":"192.168.10.103","app":"remote","message":"Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '\/var\/lib\/mysql\/mysql.sock' (13)","level":4,"time":"2016-07-20T17:24:45+00:00","method":"GET","url":"\/status.php","user":"--"}


#2

This mostly means that either your mysql server is not running or pointing to a wrong socket. Possible solutions are for example:



#3

Thanks! Ticket resolved.

chown mysql:mysql -R /var/lib/mysql/*
chmod 755 -R /var/lib/mysql/*