If you wish to change the data location, after running Nextcloud for a while, you need to make several changes:
Run occ commands as the system user that owns the Nextcloud files su - www-data -s /bin/bash
cd /path/to/nextcloud/
php occ maintenance:mode --onThe webserver must have access to the new datadirectory location
Just changing the config/config.php will add a new local::/path entry in oc_storages and Team folders will not show the files anymore
select * from `oc_storages` where id like 'local::%';
+------------+----------------------------+-----------+--------------+
| numeric_id | id | available | last_checked |
+------------+----------------------------+-----------+--------------+
| 2 | local::/var/www/html/data/ | 1 | NULL |
+------------+----------------------------+-----------+--------------+
update `oc_storages` set id='local::/data/' where numeric_id=2cd /path/to/nextcloud/
php occ files:scan --all
php occ files:repair-tree
php occ groupfolders:scancd /path/to/nextcloud/
php occ maintenance:mode --off