Bookstack database issues

Sorry to necro this, but aware is correct. DB_PASS appears to be being ignored. I was having the same issue with the connection attempting to connect to the Mysql DB and not providing a password. Changing the env var to DB_PASSWORD corrected the issue and the instance now connects to the database correctly.

I want to add more to @miversen33’s comment as he help fix my issue.

When he said DB_PASS was being ignored, that was what was causing my issue. Not sure if someone needs to revisit if that’s even correct or just base on something else that cause it to not use that variable.

This DB_PASS is part of the docker-compose.yml file, I changed it to DB_PASSWORD and it worked.



version: “2”
services:
bookstack:
image: ghcr.io/linuxserver/bookstack
container_name: bookstack
environment:
- PUID=1000
- PGID=1000
- APP_URL=
- DB_HOST=bookstack_db
- DB_USER=bookstack
- DB_PASS=
- DB_DATABASE=bookstackapp
volumes:
- /path/to/data:/config
ports:
- 6875:80
restart: unless-stopped
depends_on:
- bookstack_db
bookstack_db:
image: ghcr.io/linuxserver/mariadb
container_name: bookstack_db
environment:
- PUID=1000
- PGID=1000
- MYSQL_ROOT_PASSWORD=
- TZ=Europe/London
- MYSQL_DATABASE=bookstackapp
- MYSQL_USER=bookstack
- MYSQL_PASSWORD=
volumes:
- /path/to/data:/config
restart: unless-stopped

2 Likes

Hi,

Changing the variable name from DB_PASS to DB_PASSWORD in the compose file solved my problem.

Just to help some others who might have a similar problem.

1 Like

thanks for reporting, i will fix the readme here in a few minutes

update: this is a deeper issue, we’ll work on it, thanks

are all of you using passwords with special characters and if so, what are those characters?

Hi driz,

Yes, i use special character Slash /

Yes! This solved my problem!

please note that this isn’t a fix, it’s a bypass of a function. It happens to work because of an error on our end regarding special characters.

I changed DB_PASS into DB_PASSWORD - that seems just the solution not a bypass?

as I just said, it is a bypass, not a true fix. Sorry if my statement was unclear

I can confirm this, changed my password to a more plain string without special characters and it worked with the DB_PASS variable. The characters I was using were

! & * #

@driz I can confirm that using passwords with special characters is still an issue as of 22.02.3-ls3. Looking at past releases I do not see this as being corrected in the changelogs (maybe I missed it?).
For reference, my passwords contain various characters including:

! @ # < > . - _ & § ( )

Any update on whether this was or will be addressed? Thanks!

I believe I am having the same issue on unRAID getting it to work with both MySQL and MariaDB.

Getting access denied but I’m using the correct password and I’m able to use other services with those databases without issue.

we made an attempt which clearly didn’t fix it since you still have the issue. I suspect ill just push a PR to update the readme and instruct users to set the password directly in mariadb for passwords with special characters as opposed to use compose.

I had the exact same problem. Changing DB_PASS to DB_PASSWORD worked.

2 Likes

Same password problem here.
Changing DB_PASS to DB_PASSWORD worked
No special characters in the password, similar to this: abcec1q123vx6t
Fresh deployment from Package bookstack · GitHub

It did not work on my end. :confused:

hello all, we have not forgotten about you.
We recently discovered some other combinations that broke the sed we use in db_pass.

if you have started bypassing our sed by using db_password, it would be very helpful if some of you could test again.

fix db password setting (sed escape &) by aptalca · Pull Request #154 · linuxserver/docker-bookstack (github.com)
is what we are hoping will either fully resolve or at least partially resolve some of the issues.

This issue still exists on a fresh install from today, I suspect because the recent pull only solves for & and no other special characters that may need escaping.

I had to change DB_PASS to DB_PASSWORD and it resolved.

My .env file has the password in quotes. Special characters present are $!# in DB_PASSWORD and #@^$ in MYSQL_ROOT_PASSWORD.

Check the file /config/www/.env and see if and how the password var in there differs from your password

The password in /config/www/.env is identical to what is in quotes in my .env file. I removed the quotes around DB_PASS in .env and tried again, but the error persisted. I ran a few more tests to try to narrow it down.

This is the error in ./config/databases/bookstack-db.err

2023-01-12 22:20:42 48 [Warning] Access denied for user 'bookstack'@'bookstack.bookstack_default' (using password: YES)

Testing mysql user/pass from the db container

root@bookstack-db:/# mysql -u$MYSQL_USER -p$MYSQL_PASSWORD
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.5.13-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| bookstackapp       |
| information_schema |
+--------------------+
2 rows in set (0.000 sec)

MariaDB [(none)]> use bookstackapp;
Database changed
MariaDB [bookstackapp]> show tables;
Empty set (0.000 sec)

MariaDB [bookstackapp]>

The app container can ping it

root@bookstack:/# ping -c2 $(printenv | awk -F= '/DB_HOST/ {print $NF}')
PING bookstack-db (172.22.0.2): 56 data bytes
64 bytes from 172.22.0.2: seq=0 ttl=64 time=0.075 ms
64 bytes from 172.22.0.2: seq=1 ttl=64 time=0.072 ms

--- bookstack-db ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.072/0.073/0.075 ms

The app container can hit the db container on 3306 compared to a failure on 12345

root@bookstack:/# timeout 5 bash -c "</dev/tcp/$(printenv | awk -F= '/DB_HOST/ {print $NF}')/3306"
root@bookstack:/# echo $?
0
root@bookstack:/# timeout 5 bash -c "</dev/tcp/$(printenv | awk -F= '/DB_HOST/ {print $NF}')/12345"
bash: connect: Connection refused
bash: line 1: /dev/tcp/bookstack-db/12345: Connection refused
root@bookstack:/# echo $?
1

Here’s another test for the db connection from app container

root@bookstack:/# php /app/www/artisan tinker
Psy Shell v0.11.9 (PHP 8.0.25 — cli) by Justin Hileman
> DB::connection()->getPdo();

   PDOException  SQLSTATE[HY000] [1045] Access denied for user 'bookstack'@'bookstack.bookstack_default' (using password: YES).

I also tested the mysql connection from my local machine to the docker host after exposing the mysql port on the db container.

$ mysql -ubookstack -p -h docker02 -P 13306
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.5-10.5.13-MariaDB-log MariaDB Server

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| bookstackapp       |
| information_schema |
+--------------------+
2 rows in set (0.00 sec)

After all this I went ahead and changed

- DB_PASS=${DB_PASS}

to

- DB_PASSWORD=${DB_PASS}

in my compose file and it worked without changing anything else.

I have it running just fine right now with that change in place, but I’m happy to test things further if needed.