linuxserver / docker-bookstack

A Docker container for the BookStack documentation wiki
GNU General Public License v3.0
796 stars 109 forks source link

[BUG] Access denied for user 'database_username'@'bookstack.bookstack_default' #238

Closed synergy1990 closed 1 hour ago

synergy1990 commented 3 hours ago

Is there an existing issue for this?

Current Behavior

Access denied for user 'database_username'@'bookstack.bookstack_default' I guess there is something wrong in the init script and especially with the connection to the database. It might work, when everything was setup correctly with a previous version already and it's just the container being updated, but it definitely fails on an initial setup.

It fails with most recent image: lscr.io/linuxserver/bookstack:latest But WORKS with this one: lscr.io/linuxserver/bookstack:24.10.20241009

Expected Behavior

It should rather work - as it did in the image: lscr.io/linuxserver/bookstack:24.10.20241009

Also I dislike that the API_KEY-creation is not part of the init-script anymore!

Steps To Reproduce

I completely removed the stack (as it is called in Portainer), the containers, the volumes and did a system prune -a. It works for the 20241009-image. It always fails with the current one.

Environment

- OS: Ubuntu Server 24.04.01 LTS
- How docker service was installed:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done && \
sudo apt-get update && \
sudo apt-get install ca-certificates curl -y  && \
sudo install -m 0755 -d /etc/apt/keyrings && \
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc && \
sudo chmod a+r /etc/apt/keyrings/docker.asc && \
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && \
sudo apt-get update && \
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y && \
sudo usermod -aG docker $USER

CPU architecture

x86-64

Docker creation

services:
  bookstack:
    image: lscr.io/linuxserver/bookstack:latest
    container_name: bookstack
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Berlin
      - APP_URL=http://192.168.144.31:6875
      - APP_KEY=WsuTl38ldEY2B14c8FL5hhWlu1v35mTwIXr5Oz+Zitc=
      - DB_HOST=bookstack_db
      - DB_PORT=3306
      - DB_USER=bookstack
      - DB_PASS=mybookstack
      - DB_DATABASE=bookstackapp
    volumes:
      - bookstack:/config
    ports:
      - 6875:80
    restart: unless-stopped
    depends_on:
      - bookstack_db

  bookstack_db:
    image: lscr.io/linuxserver/mariadb
    container_name: bookstack_db
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Berlin
      - MYSQL_ROOT_PASSWORD=mybookstackrootpw
      - MYSQL_DATABASE=bookstackapp
      - MYSQL_USER=bookstack
      - MYSQL_PASSWORD=mybookstack
    volumes:
      - bookstackdb:/config
    restart: unless-stopped

volumes:
  bookstack:
  bookstackdb:

Afterwards I run `docker run -it --rm --entrypoint /bin/bash lscr.io/linuxserver/bookstack:latest appkey` and pasted the output to the environmental variable API_KEY= and restarted the container.

Container logs

[migrations] started
[migrations] 01-nginx-site-confs-default: skipped
[migrations] 02-default-location: skipped
[migrations] done
───────────────────────────────────────
      ██╗     ███████╗██╗ ██████╗
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝
   Brought to you by linuxserver.io
───────────────────────────────────────
To support LSIO projects visit:
https://www.linuxserver.io/donate/
───────────────────────────────────────
GID/UID
───────────────────────────────────────
User UID:    1000
User GID:    1000
───────────────────────────────────────
Linuxserver.io version: v24.10-ls170
Build-date: 2024-10-21T18:29:24+00:00
───────────────────────────────────────

using keys found in /config/keys
Waiting for DB to be available
   Illuminate\Database\QueryException 
  SQLSTATE[HY000] [1045] Access denied for user 'database_username'@'bookstack.bookstack_default' (using password: YES) (Connection: mysql, SQL: select table_name as `name`, (data_length + index_length) as `size`, table_comment as `comment`, engine as `engine`, table_collation as `collation` from information_schema.tables where table_schema = 'bookstackapp' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)
  at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:829
    825▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
    826▕                 );
    827▕             }
    828▕ 
  ➜ 829▕             throw new QueryException(
    830▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    831▕             );
    832▕         }
    833▕     }
      +36 vendor frames 
  37  /app/www/artisan:35
      Illuminate\Foundation\Console\Kernel::handle()
[custom-init] No custom files found, skipping...
[ls.io-init] done.
github-actions[bot] commented 3 hours ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

thespad commented 2 hours ago

The app key and database information should already have been present in the .env file in your /config/www directory. By nuking everything you've removed that and will need to ensure it matches the readme as some of the DB envs have been renamed to match the upstream values.

The APP_KEY needs to be copied as-is from what is generated, yours is missing the start and will not load correctly even once you've fixed the DB auth issues.

synergy1990 commented 1 hour ago

Holy! I didn't see, these changes. To clearify it for others: USER and PASS were changed to USERNAME and PASSWORD.

Added the "base64:" to the string - now everything is working (again) as It should! Thank you so much and have a nice weekend! :)