Change the dbtableprefix on a running docker instance

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