I’m trying to set up Nextcloud using the official Docker image and a MariaDB RDS instance on AWS.
I am supplying the following environment variables:
MYSQL_DATABASE=nextcloudThis database does not exist yetMYSQL_USER=nextcloudThis is the “root” user of the RDS instanceMYSQL_PASSWORDThe password generated for the “root” user.MYSQL_HOSTThe hostname of the RDS instance.
To create my initial admin user, I’m supplying the following environment variables:
NEXTCLOUD_ADMIN_USER=oliverNEXTCLOUD_ADMIN_PASSWORDA randomly generated 32 character string.
When the container starts, the setup tries to create the admin user and the database and then falls into a loop of reattempting this process:
Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1044] Access denied for user 'oc_oliver'@'%' to database 'nextcloud'
Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1044] Access denied for user 'oc_oliver1'@'%' to database 'nextcloud'
Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1044] Access denied for user 'oc_oliver2'@'%' to database 'nextcloud'
...
I read through a lot of similar posts, like Error creating admin user, but was unable to relate them to my situation. As the error seems to be most commonly caused by the supplied user not having sufficient permissions, but I am supplying the use with the highest possible permissions, which is also the only user on the MariaDB instance. So I don’t think that’s the problem.
I also tried not supplying the NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD environment variables, but then I receive the same error in the web UI during setup.
When I run SHOW GRANTS FOR 'oc_oliver' on the MariaDB instance, I receive the following result:
GRANT USAGE ON *.* TO 'oc_oliver'@'%' IDENTIFIED BY PASSWORD '*7F49DDC6...'
That suggests to me that the user should have the ability to connect to the database just fine.
I then tried to use MySQL instead of MariaDB, which results in the error:
The username is already being used
I have also tried using a Postgres database instead, but that has different issues. When I provision the RDS instance with a new database nextcloud, I get the error:
Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[08006] [7] FATAL: permission denied for database "nextcloud"
DETAIL: User does not have CONNECT privilege.
Can't Install Nextcloud - pgsql CONNECT privilege suggests that you can let the installer create the database and then this would work. I tried that, but then I receive the error:
Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[08006] [7] FATAL: database "nextcloud_prod" does not exist