Error Message with occ "Storage could not be selected nor selected from the database"

Nextcloud version (eg, 12.0.2): 15.04
Operating system and version (eg, Ubuntu 17.04): Ubuntu 16.04
Apache or nginx version (eg, Apache 2.4.25): 2.4.3.8
PHP version (eg, 7.1): 7.2.6

The issue you are facing:

I tried to use the occ command (in order to remove encryption among other things, but upon calling occ, I always get an error message. Nextcloud itselt works fine so far.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Goto Nextcloud Folder
  2. Any combination of “…php occ” command

Errormessage:

An unhandled exception has been thrown:
RuntimeException: Storage could neither be inserted nor be selected from the database in /nextcloud/lib/private/Files/Cache/Storage.php:82
Stack trace:
#0 /nextcloud/lib/private/Files/Cache/Cache.php(103): OC\Files\Cache\Storage->__construct(Object(OCA\Files_Trashbin\Storage))
#1 /nextcloud/lib/private/Files/Storage/Common.php(333): OC\Files\Cache\Cache->__construct(Object(OCA\Files_Trashbin\Storage))
#2 /nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(393): OC\Files\Storage\Common->getCache('appdata_ocf6iur...', Object(OCA\Files_Trashbin\Storage))
#3 /nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(393): OC\Files\Storage\Wrapper\Wrapper->getCache('appdata_ocf6iur...', Object(OCA\Files_Trashbin\Storage))
#4 /nextcloud/lib/private/Files/View.php(1318): OC\Files\Storage\Wrapper\Wrapper->getCache('appdata_ocf6iur...')
#5 /nextcloud/lib/private/Files/View.php(1374): OC\Files\View->getCacheEntry(Object(OCA\Files_Trashbin\Storage), 'appdata_ocf6iur...', '/appdata_ocf6iu...')
#6 /nextcloud/lib/private/Files/Node/Root.php(198): OC\Files\View->getFileInfo('/appdata_ocf6iu...')
#7 [internal function]: OC\Files\Node\Root->get('/appdata_ocf6iu...')
#8 /nextcloud/lib/private/Files/Node/LazyRoot.php(64): call_user_func_array(Array, Array)
#9 /nextcloud/lib/private/Files/Node/LazyRoot.php(141): OC\Files\Node\LazyRoot->__call('get', Array)
#10 /nextcloud/lib/private/Files/AppData/AppData.php(81): OC\Files\Node\LazyRoot->get('appdata_ocf6iur...')
#11 /nextcloud/lib/private/Files/AppData/AppData.php(107): OC\Files\AppData\AppData->getAppDataFolder()
#12 /nextcloud/lib/private/Template/IconsCacher.php(78): OC\Files\AppData\AppData->getFolder('icons')
#13 [internal function]: OC\Template\IconsCacher->__construct(Object(OC\Log), Object(OC\Files\AppData\Factory), Object(OC\URLGenerator), Object(OC\AppFramework\Utility\TimeFactory))
#14 /nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(81): ReflectionClass->newInstanceArgs(Array)
#15 /nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(98): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#16 /nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(119): OC\AppFramework\Utility\SimpleContainer->resolve('OC\\Template\\Ico...')
#17 /nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Template\\Ico...')
#18 /nextcloud/lib/private/Server.php(980): OC\ServerContainer->query('OC\\Template\\Ico...')
#19 /nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#20 /nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet('OC\\Template\\SCS...')
#21 /nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Template\\SCS...')
#22 /nextcloud/lib/private/Repair.php(145): OC\ServerContainer->query('OC\\Template\\SCS...')
#23 /nextcloud/core/register_command.php(143): OC\Repair::getRepairSteps()
#24 /nextcloud/lib/private/Console/Application.php(118): require_once('/hp/cr/aa/na/ww...')
#25 /nextcloud/console.php(95): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 /nextcloud/occ(11): require_once('/hp/cr/aa/na/ww...')
#27 {main}ftp262959-2721274@sh-74:~/www/nextcloud$ uname -a

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'xxx',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' => 
  array (
    0 => 'www.domain.de',
  ),
  'datadirectory' => '/xxx/nextcloud/data',
  'overwrite.cli.url' => 'https://www.domain.de',
  'dbtype' => 'mysql',
  'version' => '15.0.4.0',
  'dbname' => 'xxx',
  'dbhost' => 'xxx',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'xxx',
  'dbpassword' => 'xxx',
  'installed' => true,
  'mail_from_address' => 'info',
  'mail_smtpmode' => 'sendmail',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_domain' => 'domain.de',
  'forceSSLforSubdomains' => true,
  'forcessl' => true,
  'updater.release.channel' => 'beta',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 0,
  'overwriteprotocol' => 'https',
  'filelocking.enabled' => false,
  'twofactor_enforced' => 'true',
  'twofactor_enforced_groups' => 
  array (
  ),
  'twofactor_enforced_excluded_groups' => 
  array (
  ),
);

The output of your Apache/nginx/system log in /var/log/____:

No error Message in the log

upppp… same here