When trying to create the account on first setup from the docker, the database connection fails with error:
Error while trying to create admin user: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [1045] Access denied for user ânextcloudâ@â172.23.0.2â (using password: YES)
The surprising thing is that when I try to connect to the database with the same parameters directly from the docker image itself (I used docker-compose exec app bash and then apt update && apt install mariadb-client before to test this), I actually am able to access no problem from the terminal of the docker image.
The MariaDB server is running on port 3338 of the host machine running Docker (which also has hostname ânasâ). Below is the docker-compose.yml Iâm using:
My guess is your password is being interpreted incorrectly in the environment section. Specifically the ' character. There are some subtle bits to Composeâs interpretation of values depending on how theyâre provided and IIRC some generational differences too.
To see how Compose is parsing your docker-compose.yml passwords run:
docker compose config | grep PASSWORD
There are some other caveats, but itâs probable that the following will work in your case:
- MYSQL_PASSWORD=mypassword
i.e. If youâre using the single quotes, remove them if youâre using = value assignment.
I think you were right about this. By checking your command it does seem docker-compose was reading the quotes as literal quotes.
However, this wasnât the whole problem, because Iâm still getting the same error.
Also, I was typing the password right in the web UI (since the setup asks for it when it fails the first time) which I assume no longer uses the MYSQL_PASSWORD variable, and still I was getting the same error.
Just to make sure it wasnât because of weird characters, I changed the password to something simple, like âTest_password1â, but the result is the same. And yet mysql nextcloud -h nas -P 3338 --user nextcloud --password=Test_password1 from the container works.
Iâve also tried using the IP instead of the DNS name, but the result was also the same.
Sorry for the delay answering back (I had to go on a trip).
The docker-compose version in my nas was:
docker-compose version 1.28.5, build 24fb474e
But Iâve updated now to v2.19.0 to check and the result is the same.
Ok⌠Iâve tried now choosing the SQLite option, but I obtain the exact same error, so the issue might not really be with the MySQL connection.
I can see that in the nextcloud.log the following line appears:
{"reqId":"dSb6qsPPQ5uxQbPPcdDw","level":2,"time":"2023-07-09T17:57:50+00:00","remoteAddr":"172.24.0.1","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":"Host nas was not connected to because it violates local access rules","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36","version":"27.0.0.8","data":[]}
âHost nas was not connected to because it violates local access rulesâ
Where are those local access rules coming from?
I tried adding 'allow_local_remote_servers' => true, to the config.php as suggested here, but it did not help.