Nextcloud 19.0.1 change data directory

After snap install nextcloud in Ubuntu18.04 successfully, I want to change the default data directory from /var/snap/nextcloud/common/nextcloud/data to my own data folder like /mnt/md1/data,so firstly , I copy the data folder with command: cp /var/snap/nextcloud/common/nextcloud/data /mnt/md1/data -R -P(I also chmod 777 /mnt/md1/data -R, not working), then edit /var/snap/nextcloud/22400/nextcloud/config/config.php, set datadirectory = /mnt/md1/data. But I could never access nextcloud manager page any more.
Is there anything I should do? Thanks very much!

The Error Message:
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.

root@yunxuan:/home/yunxuan# ls /var/snap/nextcloud/common/nextcloud/data/ -a -l
total 44
drwxrwx— 8 root root 4096 7月 23 22:47 .
drwxr-x— 4 root root 4096 7月 23 22:06 …
drwxr-xr-x 9 root root 4096 7月 24 14:23 appdata_oc1z5vaav8k3
drwxr-xr-x 2 root root 4096 7月 23 22:07 files_external
-rw-r–r-- 1 root root 542 7月 23 22:07 .htaccess
-rw-r–r-- 1 root root 0 7月 23 22:07 index.html
drwxr-xr-x 5 root root 4096 7月 23 22:48 jinhua
drwxr-xr-x 4 root root 4096 7月 24 00:02 jinyan
-rw-r----- 1 root root 6440 7月 23 22:37 nextcloud.log
-rw-r–r-- 1 root root 0 7月 23 22:07 .ocdata
drwxr-xr-x 5 root root 4096 7月 23 22:49 yunxuan

root@yunxuan:/home/yunxuan# ls -a -l /mnt/md1/data/
total 44
drwxr-x— 8 root root 4096 7月 24 15:27 .
drwxr-xr-x 3 root root 4096 7月 24 15:27 …
drwxr-xr-x 9 root root 4096 7月 24 15:27 appdata_oc1z5vaav8k3
drwxr-xr-x 2 root root 4096 7月 24 15:27 files_external
-rw-r–r-- 1 root root 542 7月 24 15:27 .htaccess
-rw-r–r-- 1 root root 0 7月 24 15:27 index.html
drwxr-xr-x 5 root root 4096 7月 24 15:27 jinhua
drwxr-xr-x 4 root root 4096 7月 24 15:27 jinyan
-rw-r----- 1 root root 6440 7月 24 15:27 nextcloud.log
-rw-r–r-- 1 root root 0 7月 24 15:27 .ocdata
drwxr-xr-x 5 root root 4096 7月 24 15:27 yunxuan

almost the same folder