Database permissions not correct after sudo ncp-dist-upgrade

Hello Folks!

I’m a newbee but very motivated to get thing correctly working.
I had a working NextCloudPi for a few weeks running.
I have a Backup of my SD Card with NextcloudPi 23.0.2 and PHP8.0
On a raspberry Pi not in docker.
I duplicated it and i upgraded via sudo `ncp-dist-upgrade’.

Nextcloud is coming up after reboot. And i can’t log in into the backend.

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.

NextCloudPi Panel says this:

Something went wrong. Try refreshing the page

In general i think it is a database permission issue.
I was able to log in several times and get some ‘Failed to connect to the database …’ errors.
Unfortunately i can’t roll back, because the original system (Buster) can’t acess the external Data Base (USB) anymore.

How can i correctly start to debug whats going on.
I have access to the System via ssh.

systemctl status mariadb.service

● mariadb.service - MariaDB 10.5.12 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/mariadb.service.d
             └─ncp-delay-automount.conf
     Active: activating (start-pre) since Mon 2022-03-14 23:53:32 GMT; 4s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 10248 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 10249 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 10251 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && syst>
Cntrl PID: 10347 (sleep)
      Tasks: 1 (limit: 8987)
        CPU: 260ms
     CGroup: /system.slice/mariadb.service
             └─10347 /bin/sleep 20

Mar 14 23:53:32 nextcloudpi systemd[1]: Starting MariaDB 10.5.12 database server...
lines 1-17/17 (END)

Previously i moved the Database to :
/media/myCloudDrive/Database/

But i didn’t see anything about it that its working in that directory :pensive:

Here is the additional output of ncp-report

<–! Paste this in GitHub report →

NextCloudPi diagnostics

NextCloudPi version  v1.46.9
NextCloudPi image    NextCloudPi_10-08-21
OS                   Debian GNU/Linux 11. 5.10.103-v8+ (aarch64)
automount            yes
USB devices          sda sdb 
datadir              /media/myCloudDrive/Data/data
data in SD           no
data filesystem      ext2/ext3
data disk usage      155G/4.6T
rootfs usage         7.7G/59G
swapfile             /var/swap
dbdir                /media/myCloudDrive/Database
Nextcloud check      error
HTTPD service        up
PHP service          up
MariaDB service      down
Redis service        up
HPB service          down
Postfix service      up
internet check       ok
port check 80        open
port check 443       open
IP                   ***REMOVED SENSITIVE VALUE***
gateway              ***REMOVED SENSITIVE VALUE***
interface            eth0
certificates         ***REMOVED SENSITIVE VALUE***
NAT loopback         no
uptime               53min

Nextcloud configuration

An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused in /var/www/nextcloud/lib/private/DB/Connection.php:87
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\DB\Connection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/nextcloud/lib/private/DB/Connection.php(237): Doctrine\DBAL\Connection->executeQuery()
#3 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()
#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(287): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/nextcloud/lib/private/AppConfig.php(344): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/nextcloud/lib/private/AppConfig.php(109): OC\AppConfig->loadConfigValues()
#7 /var/www/nextcloud/lib/private/AppConfig.php(300): OC\AppConfig->getApps()
#8 /var/www/nextcloud/lib/private/legacy/OC_App.php(972): OC\AppConfig->getValues()
#9 /var/www/nextcloud/lib/private/Server.php(692): OC_App::getAppVersions()
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\Server->OC\{closure}()
#11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#12 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet()
#13 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(182): OC\AppFramework\Utility\SimpleContainer->get()
#16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#17 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet()
#19 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#20 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#21 /var/www/nextcloud/lib/private/Server.php(1079): OC\AppFramework\Utility\SimpleContainer->get()
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\Server->OC\{closure}()
#23 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#24 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet()
#25 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#26 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#27 /var/www/nextcloud/lib/private/Server.php(2040): OC\AppFramework\Utility\SimpleContainer->get()
#28 /var/www/nextcloud/lib/private/Files/View.php(118): OC\Server->getLockingProvider()
#29 /var/www/nextcloud/lib/private/Server.php(439): OC\Files\View->__construct()
#30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\Server->OC\{closure}()
#31 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#32 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet()
#33 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#35 /var/www/nextcloud/lib/private/Server.php(1403): OC\AppFramework\Utility\SimpleContainer->get()
#36 /var/www/nextcloud/lib/base.php(594): OC\Server->boot()
#37 /var/www/nextcloud/lib/base.php(1087): OC::init()
#38 /var/www/nextcloud/console.php(48): require_once('...')
#39 /var/www/nextcloud/occ(11): require_once('...')
#40 {main}
HTTPd logs

[Tue Mar 15 00:00:01.688235 2022] [ssl:warn] [pid 1219] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 15 00:00:01.701171 2022] [ssl:error] [pid 1219] AH02217: ssl_stapling_init_cert: can't retrieve issuer certificate! [subject: CN=archlinux / issuer: CN=archlinux / serial: 18C088C8F787E3CFD6C7C76280DC1F392C6E3DC2 / notbefore: Oct  8 19:39:52 2021 GMT / notafter: Oct  6 19:39:52 2031 GMT]
[Tue Mar 15 00:00:01.701227 2022] [ssl:error] [pid 1219] AH02604: Unable to configure certificate localhost:4443:0 for stapling
[Tue Mar 15 00:00:01.701329 2022] [http2:warn] [pid 1219] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Tue Mar 15 00:00:01.841867 2022] [mpm_prefork:notice] [pid 1219] AH00163: Apache/2.4.52 (Debian) OpenSSL/1.1.1k configured -- resuming normal operations
[Tue Mar 15 00:00:01.841965 2022] [core:notice] [pid 1219] AH00094: Command line: '/usr/sbin/apache2'

Database logs

2022-03-14  9:08:19 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-03-14  9:08:19 0 [Note] InnoDB: 10.3.31 started; log sequence number 9544089836; transaction id 9150026
2022-03-14  9:08:19 0 [Note] InnoDB: Loading buffer pool(s) from /media/myCloudDrive/Database/ib_buffer_pool
2022-03-14  9:08:19 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-03-14  9:08:20 0 [Note] Server socket created on IP: '127.0.0.1'.
2022-03-14  9:08:20 0 [Note] Reading of all Master_info entries succeeded
2022-03-14  9:08:20 0 [Note] Added new Master_info '' to hash table
2022-03-14  9:08:20 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '10.3.31-MariaDB-0+deb10u1'  socket: '/run/mysqld/mysqld.sock'  port: 3306  Debian 10
2022-03-14  9:08:33 0 [Note] InnoDB: Buffer pool(s) load completed at 220314  9:08:33
2022-03-14 12:15:59 0 [Note] /usr/sbin/mysqld (initiated by: unknown): Normal shutdown
2022-03-14 12:15:59 0 [Note] Event Scheduler: Purging the queue. 0 events
2022-03-14 12:15:59 0 [Note] InnoDB: FTS optimize thread exiting.
2022-03-14 12:15:59 0 [Note] InnoDB: Starting shutdown...
2022-03-14 12:15:59 0 [Note] InnoDB: Dumping buffer pool(s) to /media/myCloudDrive/Database/ib_buffer_pool
2022-03-14 12:15:59 0 [Note] InnoDB: Buffer pool(s) dump completed at 220314 12:15:59
2022-03-14 12:16:01 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2022-03-14 12:16:01 0 [Note] InnoDB: Shutdown completed; log sequence number 9551642138; transaction id 9156778
2022-03-14 12:16:01 0 [Note] /usr/sbin/mysqld: Shutdown complete


Thank you for your help!
Tea

Ok i started to look for the Maria DB to get it back to work.

I’m now a bit lost what i can do now for the next step.

Here’s the output when i try to start Maria DB:

sudo service mariadb start

Warning: The unit file, source configuration file or drop-ins of mariadb.service changed on disk. Run 'systemctl daemon-reload' to reload units.
Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xe" for details.

systemctl status mariadb.service


Warning: The unit file, source configuration file or drop-ins of mariadb.service changed on disk. Run 'systemctl daemon-reload' to reload units.
● mariadb.service - MariaDB 10.3.31 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─ncp-delay-automount.conf
   Active: activating (start-pre) since Tue 2022-03-15 07:11:12 GMT; 14s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 8334 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
  Process: 8335 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 8337 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl se
Cntrl PID: 8445 (sleep)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/mariadb.service
           └─8445 /bin/sleep 20

Mar 15 07:11:12 nextcloudpi systemd[1]: Starting MariaDB 10.3.31 database server...

lines 1-17/17 (END)

journalctl -xe
-- 
-- The process' exit code is 'exited' and its exit status is 1.
Mar 15 07:15:15 nextcloudpi systemd[1]: mariadb.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- The unit mariadb.service has entered the 'failed' state with result 'exit-code'.
Mar 15 07:15:15 nextcloudpi systemd[1]: Failed to start MariaDB 10.3.31 database server.
-- Subject: A start job for unit mariadb.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- A start job for unit mariadb.service has finished with a failure.
-- 
-- The job identifier is 3849 and the job result is failed.
Mar 15 07:15:15 nextcloudpi sudo[10281]: pam_unix(sudo:session): session closed for user root
Mar 15 07:15:16 nextcloudpi sudo[10420]:     root : TTY=unknown ; PWD=/ ; USER=www-data ; COMMAND=/usr/bin/php /var/www/nextcloud/occ config:system:get overwrite.cli
Mar 15 07:15:16 nextcloudpi sudo[10420]: pam_unix(sudo:session): session opened for user www-data by (uid=0)
Mar 15 07:15:16 nextcloudpi sudo[10420]: pam_unix(sudo:session): session closed for user www-data
Mar 15 07:15:19 nextcloudpi sudo[10424]:     root : TTY=unknown ; PWD=/ ; USER=www-data ; COMMAND=/usr/bin/php /var/www/nextcloud/occ config:system:get overwrite.cli
Mar 15 07:15:19 nextcloudpi sudo[10424]: pam_unix(sudo:session): session opened for user www-data by (uid=0)
Mar 15 07:15:20 nextcloudpi sudo[10424]: pam_unix(sudo:session): session closed for user www-data
Mar 15 07:15:20 nextcloudpi systemd[1]: mariadb.service: Service RestartSec=5s expired, scheduling restart.
Mar 15 07:15:20 nextcloudpi systemd[1]: mariadb.service: Scheduled restart job, restart counter is at 29.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Automatic restarting of the unit mariadb.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Mar 15 07:15:20 nextcloudpi systemd[1]: Stopped MariaDB 10.3.31 database server.
-- Subject: A stop job for unit mariadb.service has finished
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- A stop job for unit mariadb.service has finished.
-- 
-- The job identifier is 3981 and the job result is done.
Mar 15 07:15:20 nextcloudpi systemd[1]: Starting MariaDB 10.3.31 database server...
-- Subject: A start job for unit mariadb.service has begun execution
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- A start job for unit mariadb.service has begun execution.
-- 
-- The job identifier is 3981.
Mar 15 07:15:23 nextcloudpi sudo[10527]:     root : TTY=unknown ; PWD=/ ; USER=www-data ; COMMAND=/usr/bin/php /var/www/nextcloud/occ config:system:get overwrite.cli
Mar 15 07:15:23 nextcloudpi sudo[10527]: pam_unix(sudo:session): session opened for user www-data by (uid=0)
Mar 15 07:15:23 nextcloudpi sudo[10527]: pam_unix(sudo:session): session closed for user www-data
Mar 15 07:15:26 nextcloudpi sudo[10531]:     root : TTY=unknown ; PWD=/ ; USER=www-data ; COMMAND=/usr/bin/php /var/www/nextcloud/occ config:system:get overwrite.cli
Mar 15 07:15:26 nextcloudpi sudo[10531]: pam_unix(sudo:session): session opened for user www-data by (uid=0)
Mar 15 07:15:26 nextcloudpi sudo[10531]: pam_unix(sudo:session): session closed for user www-data
Mar 15 07:15:29 nextcloudpi sudo[10535]:     root : TTY=unknown ; PWD=/ ; USER=www-data ; COMMAND=/usr/bin/php /var/www/nextcloud/occ config:system:get overwrite.cli
Mar 15 07:15:29 nextcloudpi sudo[10535]: pam_unix(sudo:session): session opened for user www-data by (uid=0)
Mar 15 07:15:30 nextcloudpi sudo[10535]: pam_unix(sudo:session): session closed for user www-data
Mar 15 07:15:33 nextcloudpi sudo[10539]:     root : TTY=unknown ; PWD=/ ; USER=www-data ; COMMAND=/usr/bin/php /var/www/nextcloud/occ config:system:get overwrite.cli
Mar 15 07:15:33 nextcloudpi sudo[10539]: pam_unix(sudo:session): session opened for user www-data by (uid=0)
Mar 15 07:15:33 nextcloudpi sudo[10539]: pam_unix(sudo:session): session closed for user www-data
Mar 15 07:15:36 nextcloudpi sudo[10543]:     root : TTY=unknown ; PWD=/ ; USER=www-data ; COMMAND=/usr/bin/php /var/www/nextcloud/occ config:system:get overwrite.cli
Mar 15 07:15:36 nextcloudpi sudo[10543]: pam_unix(sudo:session): session opened for user www-data by (uid=0)
Mar 15 07:15:36 nextcloudpi sudo[10543]: pam_unix(sudo:session): session closed for user www-data
Mar 15 07:15:39 nextcloudpi sudo[10547]:     root : TTY=unknown ; PWD=/ ; USER=www-data ; COMMAND=/usr/bin/php /var/www/nextcloud/occ config:system:get overwrite.cli
Mar 15 07:15:39 nextcloudpi sudo[10547]: pam_unix(sudo:session): session opened for user www-data by (uid=0)
Mar 15 07:15:39 nextcloudpi sudo[10547]: pam_unix(sudo:session): session closed for user www-data
Mar 15 07:15:40 nextcloudpi mysqld[10550]: 2022-03-15  7:15:40 0 [Note] /usr/sbin/mysqld (mysqld 10.3.31-MariaDB-0+deb10u1) starting as process 10550 ...
lines 2173-2238/2238 (END)

I really looking forward what i can do to get the database working again, i have a lot of data, calendars and contacts i want to get it back to work. :face_with_monocle:

I stopped that try and turned to the NextCloud. I Don’t use Nextcloudpi anymore.

1 Like

Yes. Sometimes i think it is the better decision to install it on your own. As long as everything works, a universal solution is nice. In case of errors, it is better to have understood every installation and configuration step.