Nextcloud upgrade problem

NethServer Version: 7.9.2009
Module: nextcloud
Yesterday I tried to upgrade nextcloud from version 1.16.4-1 to latest one passing through 1.17.1-1 to 1.18.0-1, 1.19.0-1 to finish with 1.19.1-1. Something went wrong and now i’m absolutely lost. Nextcloud is not working and the page shows thi error
Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

in config.php I still have
‘version’ => ‘20.0.9.1’,

Nextcloud.log shows this error
{“reqId”:“5qkOdeY5LPU7xDz13pBB”,“level”:3,“time”:“2021-11-20T09:10:02+00:00”,“remoteAddr”:"",“user”:"–",“app”:“cron”,“method”:"",“url”:"–",“message”:{“Exception”:“Doctrine\DBAL\DBALException”,“Message”:“Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory”,“Code”:0,“Trace”:[{“file”:"/usr/share/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php",“line”:1449,“function”:“connect”,“class”:“OC\DB\Connection”,“type”:"->",“args”:[]},{“file”:"/usr/share/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php",“line”:892,“function”:“getWrappedConnection”,“class”:“Doctrine\DBAL\Connection”,“type”:"->",“args”:[]},{“file”:"/usr/share/nextcloud/lib/private/DB/Connection.php",“line”:202,“function”:“executeQuery”,“class”:“Doctrine\DBAL\Connection”,“type”:"->",“args”:[“SELECT * FROM oc_appconfig“,[],[],null]},{“file”:”/usr/share/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php”,“line”:206,“function”:“executeQuery”,“class”:“OC\DB\Connection”,“type”:"->",“args”:[“SELECT * FROM oc_appconfig“,[],[]]},{“file”:”/usr/share/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php”,“line”:217,“function”:“execute”,“class”:“Doctrine\DBAL\Query\QueryBuilder”,“type”:"->",“args”:[]},{“file”:"/usr/share/nextcloud/lib/private/AppConfig.php",“line”:345,“function”:“execute”,“class”:“OC\DB\QueryBuilder\QueryBuilder”,“type”:"->",“args”:[]},{“file”:"/usr/share/nextcloud/lib/private/AppConfig.php",“line”:110,“function”:“loadConfigValues”,“class”:“OC\AppConfig”,“type”:"->",“args”:[]},{“file”:"/usr/share/nextcloud/lib/private/AppConfig.php",“line”:301,“function”:“getApps”,“class”:“OC\AppConfig”,“type”:"->",“args”:[]},{“file”:"/usr/share/nextcloud/lib/private/legacy/OC_App.php",“line”:949,“function”:“getValues”,“class”:“OC\AppConfig”,“type”:"->",“args”:[false,“installed_version”]},{“file”:"/usr/share/nextcloud/lib/private/Server.php",“line”:668,“function”:“getAppVersions”,“class”:“OC_App”,“type”:"::",“args”:[]},{“file”:"/usr/share/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",“line”:155,“function”:“OC\{closure}”,“class”:“OC\Server”,“type”:"->",“args”:["*** sensitive parameters replaced "]},{“file”:"/usr/share/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php",“line”:118,“function”:“OC\AppFramework\Utility\{closure}”,“class”:“OC\AppFramework\Utility\SimpleContainer”,“type”:"->",“args”:[" sensitive parameters replaced "]},{“file”:"/usr/share/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",“line”:122,“function”:“offsetGet”,“class”:“Pimple\Container”,“type”:"->",“args”:[“OC\Memcache\Factory”]},{“file”:"/usr/share/nextcloud/lib/private/ServerContainer.php",“line”:156,“function”:“query”,“class”:“OC\AppFramework\Utility\SimpleContainer”,“type”:"->",“args”:[“OC\Memcache\Factory”,true]},{“file”:"/usr/share/nextcloud/lib/private/Server.php",“line”:1677,“function”:“query”,“class”:“OC\ServerContainer”,“type”:"->",“args”:[“OC\Memcache\Factory”]},{“file”:"/usr/share/nextcloud/lib/private/Server.php",“line”:1017,“function”:“getMemCacheFactory”,“class”:“OC\Server”,“type”:"->",“args”:[]},{“file”:"/usr/share/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",“line”:155,“function”:“OC\{closure}”,“class”:“OC\Server”,“type”:"->",“args”:[" sensitive parameters replaced "]},{“file”:"/usr/share/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php",“line”:118,“function”:“OC\AppFramework\Utility\{closure}”,“class”:“OC\AppFramework\Utility\SimpleContainer”,“type”:"->",“args”:[" sensitive parameters replaced "]},{“file”:"/usr/share/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",“line”:122,“function”:“offsetGet”,“class”:“Pimple\Container”,“type”:"->",“args”:[“OCP\Lock\ILockingProvider”]},{“file”:"/usr/share/nextcloud/lib/private/ServerContainer.php",“line”:156,“function”:“query”,“class”:“OC\AppFramework\Utility\SimpleContainer”,“type”:"->",“args”:[“OCP\Lock\ILockingProvider”,true]},{“file”:"/usr/share/nextcloud/lib/private/Server.php",“line”:1977,“function”:“query”,“class”:“OC\ServerContainer”,“type”:"->",“args”:[“OCP\Lock\ILockingProvider”]},{“file”:"/usr/share/nextcloud/lib/private/Files/View.php",“line”:118,“function”:“getLockingProvider”,“class”:“OC\Server”,“type”:"->",“args”:[]},{“file”:"/usr/share/nextcloud/lib/private/Server.php",“line”:395,“function”:"__construct",“class”:“OC\Files\View”,“type”:"->",“args”:[]},{“file”:"/usr/share/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",“line”:155,“function”:“OC\{closure}”,“class”:“OC\Server”,“type”:"->",“args”:[" sensitive parameters replaced "]},{“file”:"/usr/share/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php",“line”:118,“function”:“OC\AppFramework\Utility\{closure}”,“class”:“OC\AppFramework\Utility\SimpleContainer”,“type”:"->",“args”:[" sensitive parameters replaced ***"]},{“file”:"/usr/share/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",“line”:122,“function”:“offsetGet”,“class”:“Pimple\Container”,“type”:"->",“args”:[“OC\Files\Node\HookConnector”]},{“file”:"/usr/share/nextcloud/lib/private/ServerContainer.php",“line”:156,“function”:“query”,“class”:“OC\AppFramework\Utility\SimpleContainer”,“type”:"->",“args”:[“OC\Files\Node\HookConnector”,true]},{“file”:"/usr/share/nextcloud/lib/private/Server.php",“line”:1324,“function”:“query”,“class”:“OC\ServerContainer”,“type”:"->",“args”:[“OC\Files\Node\HookConnector”]},{“file”:"/usr/share/nextcloud/lib/base.php",“line”:595,“function”:“boot”,“class”:“OC\Server”,“type”:"->",“args”:[]},{“file”:"/usr/share/nextcloud/lib/base.php",“line”:1091,“function”:“init”,“class”:“OC”,“type”:"::",“args”:[]},{“file”:"/usr/share/nextcloud/cron.php",“line”:42,“args”:["/usr/share/nextcloud/lib/base.php"],“function”:“require_once”}],“File”:"/usr/share/nextcloud/lib/private/DB/Connection.php",“Line”:72,“CustomMessage”:"–"},“userAgent”:"–",“version”:“20.0.9.1”}

and
grep nextcloud /var/log/messages
Nov 20 10:32:01 docs esmith::event[12003]: #32 /usr/share/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet(‘OC\Files\Node\H… .’)
Nov 20 10:32:01 docs esmith::event[12003]: #33 /usr/share/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query(‘OC\Files\Node\H…’ , false)
Nov 20 10:32:05 docs scl: Database MariaDB is probably initialized in /var/opt/rh/rh-mariadb105/lib/mysql-nextcloud already, nothing is done.
Nov 20 10:32:05 docs scl: If this is not the case, make sure the /var/opt/rh/rh-mariadb105/lib/mysql-nextcloud is empty before running mysql-prepare-db-dir.
I think the more importatnt is this line
Nov 20 10:32:05 docs scl: If this is not the case, make sure the /var/opt/rh/rh-mariadb105/lib/mysql-nextcloud is empty before running mysql-prepare-db-dir.
bu I don’t know how to solve the problem without reinstalling everything from scratch

Anyone can help?

Good morning.
Can you report back the outcome of the following commands?

# listing related database services
systemctl | grep mariadb
systemctl | grep mysqld

# checking status of new mariadb version used by nextcloud
systemctl status -l rh-mariadb105-mariadb@nextcloud.service

# list of databases on new mariadb instance
/opt/rh/rh-mariadb105/root/bin/mysqlshow --socket="/var/run/rh-mariadb105-mariadb/nextcloud-mysql.sock"

# list of databases on old mariadb instance
mysqlshow

# list of database users on new mariadb instance
/opt/rh/rh-mariadb105/root/bin/mysql --socket="/var/run/rh-mariadb105-mariadb/nextcloud-mysql.sock" -e 'SELECT user FROM mysql.user'

# list of database users on old mariadb instance
mysql -e 'SELECT user FROM mysql.user'

Hi Marc, thank you in adavance :

rh-mariadb105-mariadb@nextcloud.service loaded active running MariaDB 10.5 database server
system-rh\x2dmariadb105\x2dmariadb.slice loaded active active system-rh\x2dmariadb105\x2dmariadb.slice

mysqld.service loaded active running MariaDB database server

rh-mariadb105-mariadb@nextcloud.service - MariaDB 10.5 database server
Loaded: loaded (/etc/systemd/system/rh-mariadb105-mariadb@.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/rh-mariadb105-mariadb@nextcloud.service.d
└─nethserver.conf
Active: active (running) since Sat 2021-11-20 10:32:05 CET; 1h 16min ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 13154 (mysqld)
Status: “Taking your SQL requests now…”
CGroup: /system.slice/system-rh\x2dmariadb105\x2dmariadb.slice/rh-mariadb105-mariadb@nextcloud.service
└─13154 /opt/rh/rh-mariadb105/root/usr/libexec/mysqld --defaults-group-suffix=.nextcloud --basedir=/opt/rh/rh-mariadb105/root/usr

Nov 20 10:32:05 docs.arketipo-sa.it systemd[1]: Starting MariaDB 10.5 database server…
Nov 20 10:32:05 docs.arketipo-sa.it scl[13109]: Database MariaDB is probably initialized in /var/opt/rh/rh-mariadb105/lib/mysql-nextcloud already, nothing is done.
Nov 20 10:32:05 docs.arketipo-sa.it scl[13109]: If this is not the case, make sure the /var/opt/rh/rh-mariadb105/lib/mysql-nextcloud is empty before running mysql-prepare-db-dir.
Nov 20 10:32:05 docs.arketipo-sa.it mysqld-scl-helper[13154]: 2021-11-20 10:32:05 0 [Note] /opt/rh/rh-mariadb105/root/usr/libexec/mysqld (mysqld 10.5.9-MariaDB) starting as process 13154 …
Nov 20 10:32:05 docs.arketipo-sa.it systemd[1]: Started MariaDB 10.5 database server.

db1

db2

user1

user2

Can you report back the dbhost parameter from nextcloud’s config.php file?

I think the nextcloud database from old mariadb55 was not fully imported to mariadb105, only partially (I suspect that because usually when it is fully imported the old one is removed later on).

You can check for ERROR on /var/log/messages. Unless my theory is wrong you’ll find some of the nextcloud upgrade steps failed. If that is the case, can you rename the nextcloud database on mariadb105 and then run:

signal-event nethserver-nextcloud-update

Maybe you can try without renaming the database and it will work the same, but if it doesn’t, rename it.

‘dbhost’ => ‘localhost:/run/rh-mariadb105-mariadb/nextcloud-mysql.sock’

Nov 19 17:50:41 docs cockpit-bridge: ERROR 1049 (42000): Unknown database ‘nextcloud’
Nov 19 17:50:59 docs cockpit-bridge: ERROR 1049 (42000): Unknown database ‘nextcloud’
Nov 19 17:52:23 docs cockpit-bridge: ERROR 1049 (42000): Unknown database ‘nextcloud’
Nov 19 18:10:42 docs cockpit-bridge: ERROR 1049 (42000): Unknown database ‘nextcloud’
Nov 19 18:10:58 docs cockpit-bridge: ERROR 1049 (42000): Unknown database ‘nextcloud’
Nov 19 18:11:06 docs cockpit-bridge: ERROR 1049 (42000): Unknown database ‘nextcloud’
Nov 19 18:13:26 docs cockpit-bridge: ERROR 1049 (42000): Unknown database ‘nextcloud’
Nov 20 10:14:38 docs esmith::event[2926]: #40 {main}[ERROR] Can’t configure socket for mysql database
Nov 20 10:28:00 docs esmith::event[8694]: #40 {main}[ERROR] Can’t configure socket for mysql database
Nov 20 10:31:59 docs esmith::event[12003]: #40 {main}[ERROR] Can’t configure socket for mysql database
Nov 20 12:32:20 docs esmith::event[29514]: #40 {main}[ERROR] Can’t configure socket for mysql database
Nov 20 12:33:10 docs esmith::event[30794]: #40 {main}[ERROR] Can’t configure socket for mysql database
Nov 20 12:33:10 docs esmith::event[30794]: #40 {main}[ERROR] Can’t configure socket for mysql database
should I try to rename database and run ```
signal-event nethserver-nextcloud-update

I was expecting you got some other error messages…, anyway

Yes, I think so. If the database import works you may end up with nextcloud page accessible but with an error (due to the nextcloud version reported on config file, error about upgrade between multiple major versions unsupported) but we can fix that later.

Bear in mind the database import can take a long time.

I was expecting some other error messages too…
no luck anyway, I dropped nextcloud db on mariadb105 e run signal-event nethserver-nextcloud-update but nothing changed… still same error on nextcloud page, and no errors on messages or nextcloud.log

What error does occ upgrade spits out?
Also, can you share the db connection parameters from:
grep \'db /usr/share/nextcloud/config/config.php |grep -v dbpass

finally an error :
An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [1045] Access denied for user ‘nextcloud’@‘localhost’ (using password: YES) in /usr/share/nextcloud/lib/private/DB/Connection.php:87

and if I try to connect with
/opt/rh/rh-mariadb105/root/bin/mysql -u nextcloud -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘nextcloud’@‘localhost’ (using password: YES)

‘dbtype’ => ‘mysql’,
‘dbname’ => ‘nextcloud’,
‘dbhost’ => ‘localhost:/run/rh-mariadb105-mariadb/nextcloud-mysql.sock’,
‘dbport’ => ‘’,
‘dbtableprefix’ => ‘oc_’,
‘dbuser’ => ‘nextcloud’,

You can make a copy of the current dbpass (config.php) and the password you can find under /var/lib/nethserver/secrets/, compare them, and replace the password of the nextcloud mysql user on mariadb105.

ok changed password in config.php, now the user can connect to sql
running command

sudo -u apache scl enable rh-php73 – php -dmemory_limit=512M /us r/share/nextcloud/occ upgrade

now it shows
An unhandled exception has been thrown:
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘nextclo ud.oc_appconfig’ doesn’t exist in /usr/share/nextcloud/3rdparty/doctrine/dbal/sr c/Driver/PDO/Connection.php:82

also trying with
signal-event nethserver-nextcloud-update

Does the nextcloud database on mariadb105 contains tables?
If the old nextcloud database is still on mariadb55 can you connect to it with the same user (nextcloud) and dbpass?

last command did nothing new…
I’m very sorry Marc, I can’t stay more but I will be back in a couple of hours

yes, the old database is still on mariadb55 and I can connect with user nextcloud and the pass i copied from secrets

but no tables there

OK, when you have time try again renaming database on mariadb105 then calling the signal event.
See (or read) you later.

no tables on the old database?

no tables
thank you very much, see you later

ok i’m back again,
I don’t know if I’m doing right but…
I recovered old mariadb55 nextcloud database from a backup and reimported to mysql, then downgraded nextcloud app from 1.19.1.1. to 1.18.0.1 to 1.17.1.1 and now I can login again.
All users and all data are there, now I’m going to update again, cross fingers