Failed to connect to the database: Access denied for user 'root'@'localhost' in /var/www/owncloud/lib/private/DB/Connection.php

Hallo,

mein Owncloud funktioniert nach Upgrade von Ubuntu 14.04 LTS auf 16.04 nicht mehr.

Bisher hatte ich unter Ubuntu 14.04 einen gut funktionierenden Owncloud 8 laufen. Im Rahmen des Upgrades von Ubuntu 14.04 auf 16.04 wurde offensichtlich Owncloud 9,1,0,15 installiert. Ich komme darauf, da in der version.php nun diese Version steht.

Beim Zugriff auf Owncloud per Browser bleibt der Bildschirm leider weiß.

/var/log/apache2/error.log:
...
[Sun Sep 11 17:20:00.810139 2016] [:error] [pid 28688] [client 192.168.1.1:52162] PHP Fatal error: Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' in /var/www/owncloud/lib/private/DB/Connection.php:58\nStack trace:\n#0 /var/www/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()\n#1 /var/www/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()\n#2 /var/www/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()\n#3 /var/www/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(621): Doctrine\DBAL\Connection->getDatabasePlatform()\n#4 /var/www/owncloud/lib/private/DB/Connection.php(141): Doctrine\DBAL\Connection->setTransactionIsolation(2)\n#5 /var/www/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Dri in /var/www/owncloud/lib/private/DB/Connection.php on line 58
...

Ein Versuch direkt per
sudo -u www-data php occ
zuzugreifen erigt folgende Fehlermeldung:

An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' in /var/www/owncloud/lib/private/DB/Connection.php:58
Stack trace:
0 /var/www/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
1 /var/www/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
2 /var/www/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
3 /var/www/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(621): Doctrine\DBAL\Connection->getDatabasePlatform()
4 /var/www/owncloud/lib/private/DB/Connection.php(141): Doctrine\DBAL\Connection->setTransactionIsolation(2)
5 /var/www/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))
6 /var/www/owncloud/lib/private/DB/ConnectionFactory.php(120): Doctrine\DBAL\DriverManager::getConnection(Array, Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
7 /var/www/owncloud/lib/private/Server.php(410): OC\DB\ConnectionFactory->getConnection('mysql', Array)
8 /var/www/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC{closure}(Object(OC\Server))
9 /var/www/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(102): Pimple\Container->offsetGet('DatabaseConnect...')
10 /var/www/owncloud/lib/private/ServerContainer.php(87): OC\AppFramework\Utility\SimpleContainer->query('DatabaseConnect...')
11 /var/www/owncloud/lib/private/Server.php(969): OC\ServerContainer->query('DatabaseConnect...')
12 /var/www/owncloud/lib/private/Server.php(215): OC\Server->getDatabaseConnection()
13 /var/www/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC{closure}(Object(OC\Server))
14 /var/www/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(102): Pimple\Container->offsetGet('OC\Authenticati...')
15 /var/www/owncloud/lib/private/ServerContainer.php(87): OC\AppFramework\Utility\SimpleContainer->query('OC\Authenticati...')
16 /var/www/owncloud/lib/private/Server.php(219): OC\ServerContainer->query('OC\Authenticati...')
17 /var/www/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC{closure}(Object(OC\Server))
18 /var/www/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(102): Pimple\Container->offsetGet('OC\Authenticati...')
19 /var/www/owncloud/lib/private/ServerContainer.php(87): OC\AppFramework\Utility\SimpleContainer->query('OC\Authenticati...')
20 /var/www/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(150): OC\ServerContainer->query('OC\Authenticati...')
21 /var/www/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(OC\Server))
22 /var/www/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(102): Pimple\Container->offsetGet('OC\Authenticati...')
23 /var/www/owncloud/lib/private/ServerContainer.php(87): OC\AppFramework\Utility\SimpleContainer->query('OC\Authenticati...')
24 /var/www/owncloud/lib/private/Server.php(234): OC\ServerContainer->query('OC\Authenticati...')
25 /var/www/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC{closure}(Object(OC\Server))
26 /var/www/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(102): Pimple\Container->offsetGet('UserSession')
27 /var/www/owncloud/lib/private/ServerContainer.php(87): OC\AppFramework\Utility\SimpleContainer->query('UserSession')
28 /var/www/owncloud/lib/private/Server.php(846): OC\ServerContainer->query('UserSession')
29 /var/www/owncloud/lib/private/Server.php(454): OC\Server->getUserSession()
30 /var/www/owncloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC{closure}(Object(OC\Server))
31 /var/www/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(102): Pimple\Container->offsetGet('AppManager')
32 /var/www/owncloud/lib/private/ServerContainer.php(87): OC\AppFramework\Utility\SimpleContainer->query('AppManager')
33 /var/www/owncloud/lib/private/Server.php(1146): OC\ServerContainer->query('AppManager')
34 /var/www/owncloud/lib/private/legacy/app.php(284): OC\Server->getAppManager()
35 /var/www/owncloud/lib/private/legacy/app.php(105): OC_App::getEnabledApps()
36 /var/www/owncloud/lib/base.php(573): OC_App::loadApps(Array)
37 /var/www/owncloud/lib/base.php(967): OC::init()
38 /var/www/owncloud/console.php(50): require_once('/var/www/ownclo...')
39 /var/www/owncloud/occ(11): require_once('/var/www/ownclo...')

Wenn ich das richtig verstehe scheitert der Zugriff auf die Datenbank.

Wie bekomme ich das denn wieder in Griff?

Vielen Dank!

Tony

Das sollte jemand den Entwicklern im Bugtracker wie hier geschrieben melden:

https://central.owncloud.org/t/sqlstate-28000-1045-access-denied-for-user-root-localhost-using-password-yes/2305

Thank you to all.

Here´s the solution:

  1. Produce a MySQL Dump (mysqldump -u username -p --all-databases > dump.sql)
  2. Delete all mysql-packages (dpkg --purge mysql...)
  3. Reinstall mysql

mysql -u root -p

CREATE DATABASE owncloud;
GRANT ALL ON owncloud.* to 'owncloud'@'localhost' IDENTIFIED BY 'set_database_password';
FLUSH PRIVILEGES;

  1. Restore MySQL Dump (mysql -u username -p database_name < dump.sql)
  2. Backup /var/www/owncloud/config + /var/www/owncloud/data
  3. Delete all owncloud* Packages
  4. Reinstall owncloud
  5. Restore /var/www/owncloud/config + /var/www/owncloud/data from backup

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-owncloud-on-ubuntu-16-04

Thank you!

Tony