Internal Server Error on NextCloud after updating DietPi

After updating my DietPi to the last version, i tried to access NC but im getting this 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.

I can’t find were is the log file to check more details about this error.

Note: I did a backup before update the DietPi.

Hi,

I guess this is the error message on your web browser. If you are running lighttpd, logs can be found at /var/log/lighttpd

pls can you check if all services are running correctly (like database)

dietpi-services status

Hi Joulinar,

Yes that error appears in the browser, sorry for not being clear.

The output of DietPi-Services:

 DietPi-Services
─────────────────────────────────────────────────────
 Mode: status 

[  OK  ] DietPi-Services | redis-server         active (running) since Tue 2020-07-14 09:09:14 BST; 1min 51s ago
[FAILED] DietPi-Services | ● mariadb.service - MariaDB 10.3.22 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2020-07-14 09:09:19 BST; 1min 47s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 648 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
  Process: 653 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 655 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 712 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
 Main PID: 712 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"

Jul 14 09:09:14 DietPi systemd[1]: Starting MariaDB 10.3.22 database server...
Jul 14 09:09:15 DietPi mysqld[712]: 2020-07-14  9:09:15 0 [Note] /usr/sbin/mysqld (mysqld 10.3.22-MariaDB-0+deb10u1) starting as process 712 ...
Jul 14 09:09:15 DietPi mysqld[712]: 2020-07-14  9:09:15 0 [Warning] Can't create test file /var/lib/mysql/DietPi.lower-test
Jul 14 09:09:19 DietPi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Jul 14 09:09:19 DietPi systemd[1]: mariadb.service: Failed with result 'exit-code'.
Jul 14 09:09:19 DietPi systemd[1]: Failed to start MariaDB 10.3.22 database server.
[  OK  ] DietPi-Services | php7.3-fpm           active (running) since Tue 2020-07-14 09:09:19 BST; 1min 47s ago
[  OK  ] DietPi-Services | lighttpd             active (running) since Tue 2020-07-14 09:09:19 BST; 1min 47s ago
[  OK  ] DietPi-Services | cron                 active (running) since Tue 2020-07-14 09:09:19 BST; 1min 47s ago
[  OK  ] DietPi-Services | dropbear             active (running) since Tue 2020-07-14 09:09:14 BST; 1min 52s ago
[  OK  ] DietPi-Services | dietpi-ramlog        active (exited) since Tue 2020-07-14 00:03:33 BST; 9h ago
[  OK  ] DietPi-Services | dietpi-preboot       active (exited) since Tue 2020-07-14 00:03:33 BST; 9h ago
[  OK  ] DietPi-Services | dietpi-boot          active (exited) since Tue 2020-07-14 09:09:14 BST; 1min 52s ago
[  OK  ] DietPi-Services | dietpi-postboot      active (exited) since Tue 2020-07-14 09:09:14 BST; 1min 52s ago
[ INFO ] DietPi-Services | dietpi-wifi-monitor  inactive (dead)

It looks like the problem is in the DB…

The output of nano /var/log/lighttpd/error.log :


2020-07-14 09:09:19: (server.c.1464) server started (lighttpd/1.4.53)
2020-07-14 09:10:01: (mod_fastcgi.c.421) FastCGI-stderr: PHP message: {"reqId":"i0fjRZs33m286ea6dqR9","level":3,"time":"2020-07-1$

Do you have any idea of how can i solve this?

Thank you.

ok let’s check what is wrong with your database. Do you moved something to an external HDD or is everything located on your SD card?

There is an error massage pointing to some issues on creating a test file

Can't create test file /var/lib/mysql/DietPi.lower-test

pls can you do following. This will give some more inside into you system.

systemctl restart mariadb.service
journalctl -u mariadb
cat /var/log/mysql/error.log
readlink /var/lib/mysql
readlink -f /var/lib/mysql
sudo -u mysql -g mysql touch /var/lib/mysql/demo.file

I’ve turned my RPI on and I was about to test you commands in your last answer, but before I start trying those commands, I tried one more time to access my nextcloud in the Browser.
Unexpectedly, i got this message: Unable to connect. Browser can’t establish a connection to the server at “my-ip-here”.

I ran DietPi-Services, and now i got this:


DietPi-Services
─────────────────────────────────────────────────────
 Mode: status 

[  OK  ] DietPi-Services | redis-server         active (running) since Tue 2020-07-14 12:41:39 BST; 5min ago
[FAILED] DietPi-Services | ● mariadb.service - MariaDB 10.3.22 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2020-07-14 12:41:43 BST; 5min ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 654 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
  Process: 655 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 657 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 714 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
 Main PID: 714 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"

Jul 14 12:41:39 DietPi systemd[1]: Starting MariaDB 10.3.22 database server...
Jul 14 12:41:40 DietPi mysqld[714]: 2020-07-14 12:41:40 0 [Note] /usr/sbin/mysqld (mysqld 10.3.22-MariaDB-0+deb10u1) starting as process 714 ...
Jul 14 12:41:40 DietPi mysqld[714]: 2020-07-14 12:41:40 0 [Warning] Can't create test file /var/lib/mysql/DietPi.lower-test
Jul 14 12:41:43 DietPi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Jul 14 12:41:43 DietPi systemd[1]: mariadb.service: Failed with result 'exit-code'.
Jul 14 12:41:43 DietPi systemd[1]: Failed to start MariaDB 10.3.22 database server.
[  OK  ] DietPi-Services | php7.3-fpm           active (running) since Tue 2020-07-14 12:41:43 BST; 5min ago
[FAILED] DietPi-Services | ● lighttpd.service - Lighttpd Daemon
   Loaded: loaded (/lib/systemd/system/lighttpd.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2020-07-14 12:41:46 BST; 5min ago
  Process: 800 ExecStartPre=/usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf (code=exited, status=0/SUCCESS)
  Process: 805 ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf (code=exited, status=255/EXCEPTION)
 Main PID: 805 (code=exited, status=255/EXCEPTION)

Jul 14 12:41:46 DietPi systemd[1]: lighttpd.service: Service RestartSec=100ms expired, scheduling restart.
Jul 14 12:41:46 DietPi systemd[1]: lighttpd.service: Scheduled restart job, restart counter is at 5.
Jul 14 12:41:46 DietPi systemd[1]: Stopped Lighttpd Daemon.
Jul 14 12:41:46 DietPi systemd[1]: lighttpd.service: Start request repeated too quickly.
Jul 14 12:41:46 DietPi systemd[1]: lighttpd.service: Failed with result 'exit-code'.
Jul 14 12:41:46 DietPi systemd[1]: Failed to start Lighttpd Daemon.
[  OK  ] DietPi-Services | cron                 active (running) since Tue 2020-07-14 12:41:43 BST; 5min ago
[  OK  ] DietPi-Services | dropbear             active (running) since Tue 2020-07-14 12:41:38 BST; 5min ago
[  OK  ] DietPi-Services | dietpi-ramlog        active (exited) since Tue 2020-07-14 09:19:30 BST; 3h 28min ago
[  OK  ] DietPi-Services | dietpi-preboot       active (exited) since Tue 2020-07-14 09:19:30 BST; 3h 28min ago
[  OK  ] DietPi-Services | dietpi-boot          active (exited) since Tue 2020-07-14 12:41:38 BST; 5min ago
[  OK  ] DietPi-Services | dietpi-postboot      active (exited) since Tue 2020-07-14 12:41:38 BST; 5min ago
[ INFO ] DietPi-Services | dietpi-wifi-monitor  inactive (dead)

Server is not even running now…

Note: I didn’t ran the commands of your last answer yet.

You have 2 failing services now. Both web server as well as database are not working. But we would need to fix one by one. Pls can you check if you have sufficient space on your SD card

Yes I have:

Filesystem     Type     1K-blocks     Used Available Use% Mounted on
/dev/root      ext4     122648040 42840088  74800256  37% /
devtmpfs       devtmpfs   1991700        0   1991700   0% /dev
tmpfs          tmpfs      2025492        0   2025492   0% /dev/shm
tmpfs          tmpfs      2025492    16664   2008828   1% /run
tmpfs          tmpfs         5120        0      5120   0% /run/lock
tmpfs          tmpfs      2025492        0   2025492   0% /sys/fs/cgroup
tmpfs          tmpfs        51200      100     51100   1% /var/log
tmpfs          tmpfs      2025472        0   2025472   0% /tmp
/dev/mmcblk0p1 vfat        258095    53701    204394  21% /boot

I have 128 Gb Sdcard Samsung pro

ok space is not an issue and all data seems to located on the SD card as well. Pls can you perform the checks I ask for above to be able to have a look into database first

systemctl restart mariadb.service
journalctl -u mariadb
cat /var/log/mysql/error.log
readlink /var/lib/mysql
readlink -f /var/lib/mysql
sudo -u mysql -g mysql touch /var/lib/mysql/demo.file

systemctl restart mariadb.service

Failed to connect to bus: No such file or directory

Then i ran again as sudo:

sudo systemctl restart mariadb.service
Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xe" for details.



sudo journalctl -u mariadb
-- Logs begin at Thu 2019-02-14 10:11:58 GMT, end at Tue 2020-07-14 13:34:14 BST. --
Jul 14 12:41:39 DietPi systemd[1]: Starting MariaDB 10.3.22 database server...
Jul 14 12:41:40 DietPi mysqld[714]: 2020-07-14 12:41:40 0 [Note] /usr/sbin/mysqld (mysqld 10.3.22-MariaDB-0+deb10u1) starting as p
rocess 714 ...
Jul 14 12:41:40 DietPi mysqld[714]: 2020-07-14 12:41:40 0 [Warning] Can't create test file /var/lib/mysql/DietPi.lower-test
Jul 14 12:41:43 DietPi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Jul 14 12:41:43 DietPi systemd[1]: mariadb.service: Failed with result 'exit-code'.
Jul 14 12:41:43 DietPi systemd[1]: Failed to start MariaDB 10.3.22 database server.
Jul 14 13:33:14 DietPi systemd[1]: Starting MariaDB 10.3.22 database server...
Jul 14 13:33:14 DietPi mysqld[1160]: 2020-07-14 13:33:14 0 [Note] /usr/sbin/mysqld (mysqld 10.3.22-MariaDB-0+deb10u1) starting as 
process 1160 ...
Jul 14 13:33:14 DietPi mysqld[1160]: 2020-07-14 13:33:14 0 [Warning] Can't create test file /var/lib/mysql/DietPi.lower-test
Jul 14 13:33:17 DietPi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Jul 14 13:33:17 DietPi systemd[1]: mariadb.service: Failed with result 'exit-code'.
Jul 14 13:33:17 DietPi systemd[1]: Failed to start MariaDB 10.3.22 database server.



readlink /var/lib/mysql
/mnt/dietpi_userdata/mysql

readlink -f /var/lib/mysql
/mnt/dietpi_userdata/mysql


sudo -u mysql -g mysql touch /var/lib/mysql/demo.file
touch: cannot touch '/var/lib/mysql/demo.file': Permission denied

Note: Yesterday i couldn’t access /var/log/lighttpd so i ran sudo chown -R my_username /var/log/lighttpd . Maybe this caused some side effects…

And lastly (sorry for the extensive output, i had to delete some lines in the middle, they where the same error but for other directories):

sudo cat /var/log/mysql/error.log
2020-07-14 13:33:14 0 [Note] InnoDB: Using Linux native AIO
2020-07-14 13:33:14 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-07-14 13:33:14 0 [Note] InnoDB: Uses event mutexes
2020-07-14 13:33:14 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-07-14 13:33:14 0 [Note] InnoDB: Number of pools: 1
2020-07-14 13:33:14 0 [Note] InnoDB: Using generic crc32 instructions
2020-07-14 13:33:14 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-07-14 13:33:14 0 [Note] InnoDB: Completed initialization of buffer pool
2020-07-14 13:33:14 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-07-14 13:33:14 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 0 [ERROR] InnoDB: Cannot open datafile for read-only: './mysql/gtid_slave_pos.ibd' OS error: 81
2020-07-14 13:33:14 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.

..... (more lines with the same access rights errors for other directories)

2020-07-14 13:33:14 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 0 [ERROR] InnoDB: Cannot open datafile for read-only: './nextcloud/oc_webauthn.ibd' OS error: 81
2020-07-14 13:33:14 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 0 [ERROR] InnoDB: Could not find a valid tablespace file for ``nextcloud`.`oc_webauthn``. Please refer to https://mariadb.com/kb/en/innodb-data-dictionary-troubleshooting/ for how to resolve the issue.
2020-07-14 13:33:14 0 [Warning] InnoDB: Ignoring tablespace for `nextcloud`.`oc_webauthn` because it could not be opened.
2020-07-14 13:33:14 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 0 [ERROR] InnoDB: Cannot open datafile for read-only: './nextcloud/oc_whats_new.ibd' OS error: 81
2020-07-14 13:33:14 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 0 [ERROR] InnoDB: Could not find a valid tablespace file for ``nextcloud`.`oc_whats_new``. Please refer to https://mariadb.com/kb/en/innodb-data-dictionary-troubleshooting/ for how to resolve the issue.
2020-07-14 13:33:14 0 [Warning] InnoDB: Ignoring tablespace for `nextcloud`.`oc_whats_new` because it could not be opened.
2020-07-14 13:33:14 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2020-07-14 13:33:14 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-07-14 13:33:14 0 [Note] InnoDB: 10.3.22 started; log sequence number 46552637; transaction id 115418
2020-07-14 13:33:14 0 [Note] InnoDB: Loading buffer pool(s) from /mnt/dietpi_userdata/mysql/ib_buffer_pool
2020-07-14 13:33:14 2 [ERROR] InnoDB: Failed to find tablespace for table `mysql`.`innodb_index_stats` in the cache. Attempting to load the tablespace with space id 2
2020-07-14 13:33:14 2 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 2 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 2 [ERROR] InnoDB: Cannot open datafile for read-only: './mysql/innodb_index_stats.ibd' OS error: 81
2020-07-14 13:33:14 2 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 2 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 2 [ERROR] InnoDB: Could not find a valid tablespace file for ``mysql`.`innodb_index_stats``. Please refer to https://mariadb.com/kb/en/innodb-data-dictionary-troubleshooting/ for how to resolve the issue.
2020-07-14 13:33:14 4 [ERROR] InnoDB: Failed to find tablespace for table `nextcloud`.`oc_authtoken` in the cache. Attempting to load the tablespace with space id 57
2020-07-14 13:33:14 4 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 4 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 4 [ERROR] InnoDB: Cannot open datafile for read-only: './nextcloud/oc_authtoken.ibd' OS error: 81
2020-07-14 13:33:14 4 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 4 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-07-14 13:33:14 4 [ERROR] InnoDB: Could not find a valid tablespace file for ``nextcloud`.`oc_authtoken``. Please refer to https://mariadb.com/kb/en/innodb-data-dictionary-troubleshooting/ for how to resolve the issue.
2020-07-14 13:33:14 2 [ERROR] InnoDB: Failed to find tablespace for table `mysql`.`innodb_table_stats` in the cache. Attempting to load the tablespace with space id 1
2020-07-14 13:33:14 0 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
2020-07-14 13:33:14 2 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 2 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 2 [ERROR] InnoDB: Cannot open datafile for read-only: './mysql/innodb_table_stats.ibd' OS error: 81
2020-07-14 13:33:14 2 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 2 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 0 [Note] Recovering after a crash using tc.log
2020-07-14 13:33:14 2 [ERROR] InnoDB: Could not find a valid tablespace file for ``mysql`.`innodb_table_stats``. Please refer to https://mariadb.com/kb/en/innodb-data-dictionary-troubleshooting/ for how to resolve the issue.
2020-07-14 13:33:14 0 [ERROR] Bad magic header in tc log
2020-07-14 13:33:14 0 [ERROR] Crash recovery failed. Either correct the problem (if it's, for example, out of memory error) and restart, or delete tc log and start mysqld with --tc-heuristic-recover={commit|rollback}
2020-07-14 13:33:14 0 [ERROR] Can't init tc log
2020-07-14 13:33:14 0 [ERROR] Aborting

2020-07-14 13:33:14 2 [ERROR] InnoDB: Failed to find tablespace for table `nextcloud`.`oc_appconfig` in the cache. Attempting to load the tablespace with space id 8
2020-07-14 13:33:14 2 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 2 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 2 [ERROR] InnoDB: Cannot open datafile for read-only: './nextcloud/oc_appconfig.ibd' OS error: 81
2020-07-14 13:33:14 2 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 2 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 2 [ERROR] InnoDB: Could not find a valid tablespace file for ``nextcloud`.`oc_appconfig``. Please refer to https://mariadb.com/kb/en/innodb-data-dictionary-troubleshooting/ for how to resolve the issue.
2020-07-14 13:33:14 2 [ERROR] InnoDB: Failed to find tablespace for table `nextcloud`.`oc_jobs` in the cache. Attempting to load the tablespace with space id 40
2020-07-14 13:33:14 2 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 2 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 2 [ERROR] InnoDB: Cannot open datafile for read-only: './nextcloud/oc_jobs.ibd' OS error: 81
2020-07-14 13:33:14 2 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:14 2 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2020-07-14 13:33:14 2 [ERROR] InnoDB: Could not find a valid tablespace file for ``nextcloud`.`oc_jobs``. Please refer to https://mariadb.com/kb/en/innodb-data-dictionary-troubleshooting/ for how to resolve the issue.
2020-07-14 13:33:14 0 [ERROR] InnoDB: Cannot open '/mnt/dietpi_userdata/mysql/ib_buffer_pool.incomplete' for writing: Permission denied
2020-07-14 13:33:17 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-07-14 13:33:17 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.

I would recommend to use user root for the time being. This way you don’t need to change user access for files and folder to be able to read them.

for lighttpd you would need to revert your changes back

chown -R www-data:www-data /var/log/lighttpd

for database, pls post

ls -la /mnt/dietpi_userdata/
ls -la /mnt/dietpi_userdata/
total 32
drwxrwxr-x 8 dt dietpi   4096 Jun  7 21:50 .
drwxr-xr-x 7 dt root     4096 Jun 10 21:45 ..
drwxrwxr-x 2 dt dietpi   4096 Jun  7 20:32 downloads
drwxrwxr-x 2 dt dietpi   4096 Jun  7 20:32 Music
drwxr-xr-x 5 dt mysql    4096 Jun 11 08:34 mysql
drwxrwx--- 6 dt www-data 4096 Jun 11 23:29 nextcloud_data
drwxrwxr-x 2 dt dietpi   4096 Jun  7 20:32 Pictures
drwxrwxr-x 2 dt dietpi   4096 Jun  7 20:32 Video

it was on purpose to change user for all directories to td? Now, database user mysql doesn’t have write access to database files anymore. Therefore your database is failing to start

drwxr-xr-x 5 dt mysql 4096 Jun 11 08:34 mysql

It seems you changed it for entire /mnt directory path

Maybe I ran that by mistake, i don’t remember. How can I revert it back?

Note:

ls -la /mnt/
total 28
drwxr-xr-x  7 dt   root   4096 Jun 10 21:45 .
drwxr-xr-x 21 root root   4096 Jul 13 22:01 ..
drwxr-xr-x  3 dt   root   4096 Jun 10 21:47 dietpi-backup
drwxrwxr-x  8 dt   dietpi 4096 Jun  7 21:50 dietpi_userdata
drwxr-xr-x  2 dt   root   4096 Jan  7  2020 ftp_client
drwxr-xr-x  2 dt   root   4096 Jan  7  2020 nfs_client
drwxr-xr-x  2 dt   root   4096 Jan  7  2020 samba

Should i run:
sudo chown -R mysql /mnt/dietpi_userdata/mysql
?

I would go to correct whole /mnt directory structure to avoid other issues.

pls do as user root

chown root:root /mnt/ /mnt/samba
chown dietpi:dietpi /mnt/dietpi_userdata /mnt/ftp_client/ /mnt/nfs_client/
chown dietpi:dietpi /mnt/dietpi_userdata/Music /mnt/dietpi_userdata/Pictures /mnt/dietpi_userdata/Video /mnt/dietpi_userdata/downloads

This will change main folder only, as I’m not sure what kind of data you have inside.
For the following 2 folder, we will do a recursive adjustment to have them changed completely.

chown -R mysql:mysql /mnt/dietpi_userdata/mysql
chown -R www-data:www-data /mnt/dietpi_userdata/nextcloud_data

A problem could be dietpi-backup folder, as you changed all files and permissions inside your backup as well. If you go to restore your system now, you will overwrite all your files with incorrect user settings. I would recommend to create a complete new backup and delete the current one, if all working fine.

I ran those commands and restated RPI.

MariaDB server is still down but this time it doesn’t show the “can’t create test file” error.

$ sudo dietpi-services status
 DietPi-Services
─────────────────────────────────────────────────────
 Mode: status 

[  OK  ] DietPi-Services | redis-server         active (running) since Tue 2020-07-14 21:11:50 BST; 6min ago
[FAILED] DietPi-Services | ● mariadb.service - MariaDB 10.3.22 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2020-07-14 21:11:54 BST; 6min ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 606 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
  Process: 607 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 613 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 670 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
 Main PID: 670 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"

Jul 14 21:11:50 DietPi systemd[1]: Starting MariaDB 10.3.22 database server...
Jul 14 21:11:51 DietPi mysqld[670]: 2020-07-14 21:11:51 0 [Note] /usr/sbin/mysqld (mysqld 10.3.22-MariaDB-0+deb10u1) starting as process 670 ...
Jul 14 21:11:54 DietPi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Jul 14 21:11:54 DietPi systemd[1]: mariadb.service: Failed with result 'exit-code'.
Jul 14 21:11:54 DietPi systemd[1]: Failed to start MariaDB 10.3.22 database server.
[  OK  ] DietPi-Services | php7.3-fpm           active (running) since Tue 2020-07-14 21:11:55 BST; 6min ago
[  OK  ] DietPi-Services | lighttpd             active (running) since Tue 2020-07-14 21:11:55 BST; 6min ago
[  OK  ] DietPi-Services | cron                 active (running) since Tue 2020-07-14 21:11:55 BST; 6min ago
[  OK  ] DietPi-Services | dropbear             active (running) since Tue 2020-07-14 21:11:49 BST; 6min ago
[  OK  ] DietPi-Services | dietpi-ramlog        active (exited) since Tue 2020-07-14 21:11:04 BST; 7min ago
[  OK  ] DietPi-Services | dietpi-preboot       active (exited) since Tue 2020-07-14 21:11:04 BST; 7min ago
[  OK  ] DietPi-Services | dietpi-boot          active (exited) since Tue 2020-07-14 21:11:49 BST; 6min ago
[  OK  ] DietPi-Services | dietpi-postboot      active (exited) since Tue 2020-07-14 21:11:49 BST; 6min ago
[ INFO ] DietPi-Services | dietpi-wifi-monitor  inactive (dead)

Pls this one again

journalctl -u mariadb
cat /var/log/mysql/error.log

And for the backup folder, what i need to do is:

rm - rf /mnt/dietpi-backup/*

And then i just run dietpi-backup right?