Unable to change dbhost
using occ config:system:set
if existing dbhost
isn't functioning
#40904
Closed
5 of 8 tasks
Labels
0. Needs triage
Pending check for reproducibility or if it fits our roadmap
27-feedback
bug
feature: occ
Bug description
In the "Auto configuration via environment variables" section of the Docker Readme, one can use
MYSQL_HOST
to set the database connection info, andNEXTCLUOD_UPDATE=1
to automate installation.The problem is when we want to change that MySQL_HOST into something else. We change the environment variable, restart the container, and we get this error:
SQLSTATE[HY000] [2006] MySQL server has gone away
.We investigate and find that, while the autoconfig.php reads environment variables, the config.php is hard-coded at installation time with the actual IP/PORTS:
OK, let's try to use the CLI command to edit that hard-coded file, like this:
We then get this error again:
SQLSTATE[HY000] [2006] MySQL server has gone away
So the
config:system:set
can't fix thedbhost
variable without trying to connect to the old, faulty dbhost!That means the only option is either to manually edit the config file, to overwrite it with
sed
, or to overwrite it entirely (which sounds complex because it has to keep all the generated secrets already present in it).Steps to reproduce
Trivial Docker-compose example that renames "db" into "db2": https://gist.github.com/gabriel-v/c6e5a1e18686f39649546c1161fadd64
Expected behavior
Nextcloud starts successfully with the new DB connection info
Installation method
Community Docker image
Nextcloud Server version
confirmed on 26, 27, latest docker images
Operating system
Debian/Ubuntu
PHP engine version
None
Web server
Apache (supported)
Database engine version
MySQL
Is this bug present after an update or on a fresh install?
Fresh Nextcloud Server install
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
Configuration report
List of activated Apps
Nextcloud Signing status
server doesn't start
Nextcloud Logs
Additional info
Found on the interwebs:
Questions
php occ config:system:set dbhost --value 1.2.3.4
be made not to connect to the previous (inaccessible) dbhost?Is there some kind of override config file we can put in the config dir, to override only the dbhost value with the actual envrionment variable set on the container?Work-Around
https://github.com/nextcloud/helm/tree/main/charts/nextcloud#multiple-configphp-file
Create file
config/dbhostoverride.config.php
with content:And add keys to this file for each value expected to change (dbport, passwords, etc.)
Suggestions
This causes a great deal of confusion: one expects the environment variable to be the source of truth for configuring the image. Inspecting the
autoconfig.php
file also does not help, because it's not obvious the$AUTOCONFIG
var is used only at install time, while the$CONFIG
var is used at run time.The text was updated successfully, but these errors were encountered: