Change the dbtableprefix on a running docker instance

I would like to ommit the table-prefix in my Mariadb Database. I tried changing my setting

   'dbtableprefix' => 'oc_',

to

   'dbtableprefix' => '',

But that gave only an Internal Server Error on the website after starting it with

docker-compose up

I also tried adding this in docker-compose.yaml:

 - NEXTCLOUD_TABLE_PREFIX=

But that had no effect, I guess it is only used during a fresh install

How can I change my table-prefix?

There seems something odd overall, I tried to reinstall my developer docker version, but there the NEXTCLOUD_TABLE_PREFIX is not working:

I figured it out:

#!/usr/bin/env bash
D=your_myriadb_docker_image_name
MYSQL_ROOT_PASSWORD=secret

ALL_TABLES=$(docker exec ${D} mysql nextcloud -p$MYSQL_ROOT_PASSWORD -e "show tables"|tail -n +2)
for i in $ALL_TABLES; do
	T="$(echo $i|sed 's/^oc_//g')"
	docker exec ${D} mysql nextcloud -p$MYSQL_ROOT_PASSWORD -e "RENAME TABLE oc_$T to $T"
done

sed "s/dbtableprefix'\s*=>\s*'oc_'/dbtableprefix' => ''/" volumes/html/config/config.php -i

BUT be aware, that a longer prefix than 3 characters is not intended to work, and will be disabled in future releases!

1 Like

Thanks, stumbled upon the same thing. Your script saved me some time, thanks :slight_smile:

But you could/should do the sed inside the apps docker container too, just to be on the safe side with permissions, the file path etc. But people doing this will know how to do that

:+1: