danielbrendel / hortusfox-web

Self-hosted collaborative plant management and tracking system for plant enthusiasts
https://www.hortusfox.com
MIT License
674 stars 34 forks source link

Failed DB Connection #301

Closed sudodaemon closed 6 days ago

sudodaemon commented 1 week ago

Describe the bug Not able to get Hortusfox started, using docker compose, in the app container it just repeats "Waiting for database to be available... Attempt 21"

and in the DB container the logs show "[Warning] Aborted connection 20 to db: 'unconnected' user: 'unauthenticated' host: '192.168.112.3' (This connection closed normally without authentication)"

To Reproduce Steps to reproduce the behavior:

  1. Configure docker compose, run it, no errors when running docker-compose

Expected behavior Make a DB connection

Screenshots If applicable, add screenshots to help explain your problem.

Software:

`version: "3.8"

services: app: image: ghcr.io/danielbrendel/hortusfox-web:latest ports:

volumes: db_data: app_images: app_logs: app_backup: app_themes: app_migrate: `

Desktop (please complete the following information):

Additional context I swear I'm not a docker newbie, I have a ton of other containers using mysql, or postgres... I just can't get this going and I'm sure its a simple thing I'm overlooking.

danielbrendel commented 1 week ago

Hi, I'm sorry it's not working on your end. This is very likely a configuration issue. I'd advise to join our Discord or use the support form in order to get usage help. Kind regards

Support contact form: https://www.hortusfox.com/support Discord server: https://discord.gg/kc6xGmjzVS

etorres4 commented 1 week ago

Hi! I was having the exact same problem as you. I was actually able to fix this problem by manually running these commands on the mariaDB container:

Note: replace the <> with whatever values you used

// (from your system's shell
$ docker compose exec db mariadb -u root
// (in mariadb shell in the container)
$ use mysql;
// hortusfox is the username here before the @
$ CREATE USER '<mysql_user>'@'%' IDENTIFIED BY '<mysql_password>';
// Create the database
$ CREATE DATABASE <mysql_database>;
// We need to give the hortusfox user access to the hortusfox database
$ GRANT ALL ON <mysql_database>.* TO '<mysql_user>'@'%';
$ FLUSH PRIVILEGES

For whatever reason not sure why, the database itself wasn't being set up. These commands manually run the steps needed for the app to communicate properly with the database.

Here are the environment variables I have set up for the server:

DB_HOST=db
DB_PORT=3306
DB_DATABASE=hortusfox
DB_USERNAME=hortusfox
DB_PASSWORD='<mysql_password>'
DB_CHARSET='utf8mb4'

And how my environment variables I set up for the db:

MYSQL_ROOT_PASSWORD='<mysql_root_password>'
MYSQL_DATABASE=hortusfox
MYSQL_USER=hortusfox
MYSQL_PASSWORD='<mysql_password>'
danielbrendel commented 6 days ago

Solution provided by user.