Closed libtech4 closed 6 months ago
Hi @libtech4, This sounds strange and looks like you'd done the main useful debugging steps already.
I noticed you were using config caching, which is something we don't document as it can cause confusion when changing env options. Just to eliminate that as a variable, can you force delete the bootstrap/cache/config.php
file and avoid caching the config (at least until getting things to a working state).
As another debug step, you could run the below from your bookstack install dir:
php artisan tinker --execute="print_r(config('database.connections.mysql'))"
This will print out the database details that BookStack would be using, post parse/caching, so you could compare the details to those you've set to ensure they're aligned.
Otherwise, another option is to enable the mysql general log (if not already enabled) and check what is reported on the mysql-server side of things when a connection is attempted, in the hopes of additional insight. I just tested this on my setup and the general log seems to log failed connection attempts.
Thank you, Dan; the issue got fixed. I deleted the database and user, recreated it, and followed your instructions by deleting the config.php file, which worked. I appreciate your help! I was looking for a documenting tool for personal use, and this was the first one I installed in my home lab and it really looks nice.
@libtech4 Good to hear that worked! I'll therefore close this off.
Attempted Debugging
Searched GitHub Issues
Describe the Scenario
This is the first time I have tried to install BookStack in a Linux VM. I have installed all the required packages, such as Ngnix, PHP, etc. I downloaded BookStack and ran composer install. No issue was found; everything went well. I updated the .env file with the database information below. Then, I ran "php artisan key:generate," and it generated a key. When I ran "php artisan migrate," I got a QueryEception error. I am using the MySQL database, and it is installed in a remote VM. I created a database and database user for BookStack. I granted all privileges. From the Stack server, I can access the MySQL server. I also created a test table using Bookstack credentials. Everything is fine, but I don't know if I am getting an error. I restarted the Ngnix service and tried to access the GUI, but it didn't come up.
Database Access details
Details
``` mysql> SELECT user, host FROM mysql.user WHERE user = 'bookstack'; +-----------+-------------------+ | user | host | +-----------+-------------------+ | bookstack | 192.168.1.216 | | bookstack | doc.homelab.local | +-----------+-------------------+ 2 rows in set (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | bookstack | | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 6 rows in set (0.00 sec) mysql> SHOW GRANTS FOR bookstack@doc.homelab.local; +--------------------------------------------------------------------------+ | Grants for bookstack@doc.homelab.local | +--------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO `bookstack`@`doc.homelab.local` | | GRANT ALL PRIVILEGES ON `bookstack`.* TO `bookstack`@`doc.homelab.local` | +--------------------------------------------------------------------------+ 2 rows in set (0.00 sec) mysql> SHOW GRANTS FOR bookstack@192.168.1.216; +----------------------------------------------------------------------+ | Grants for bookstack@192.168.1.216 | +----------------------------------------------------------------------+ | GRANT USAGE ON *.* TO `bookstack`@`192.168.1.216` | | GRANT ALL PRIVILEGES ON `bookstack`.* TO `bookstack`@`192.168.1.216` | +----------------------------------------------------------------------+ 2 rows in set (0.00 sec) [root@doc-server-01 logs]# mysql -u bookstack -h 192.168.1.212 -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 28 Server version: 8.0.36 Source distribution Copyright (c) 2000, 2024, 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 | +--------------------+ | bookstack | | information_schema | | performance_schema | +--------------------+ 3 rows in set (0.01 sec) mysql> use bookstack; Database changed mysql> create table test ( -> name varchar(255), -> city varchar(255) -> ); Query OK, 0 rows affected (1.08 sec) ```
By the way, I only added doc.homelab.local for the Bookstack server in my DNS server's zones; I'm not sure how it is showing up in the stack server. I still created users using both domain names and IP addresses. 192.168.1.212 is the IP address of the MySQL server, and 216 is the IP address of the Bookstack server. Do you have any idea how to fix the issue? Thanks,
Exact BookStack Version
Not sure where to find it.
Log Content
Details
``` 2024-05-18 01:17:37] production.ERROR: SQLSTATE[HY000] [1045] Access denied for user 'bookstack'@'doc.homelab.local' (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 = 'bookstack' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 1045): SQLSTATE[HY000] [1045] Access denied for user 'bookstack'@'doc.homelab.local' (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 = 'bookstack' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name) at /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:829) [stacktrace] #0 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php(783): Illuminate\\Database\\Connection->runQueryCallback() #1 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php(431): Illuminate\\Database\\Connection->run() #2 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php(401): Illuminate\\Database\\Connection->select() #3 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php(42): Illuminate\\Database\\Connection->selectFromWriteConnection() #4 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(165): Illuminate\\Database\\Schema\\MySqlBuilder->getTables() #5 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php(184): Illuminate\\Database\\Schema\\Builder->hasTable() #6 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(700): Illuminate\\Database\\Migrations\\DatabaseMigrationRepository->repositoryExists() #7 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(140): Illuminate\\Database\\Migrations\\Migrator->repositoryExists() #8 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Support/helpers.php(248): Illuminate\\Database\\Console\\Migrations\\MigrateCommand->Illuminate\\Database\\Console\\Migrations\\{closure}() #9 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(159): retry() #10 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(116): Illuminate\\Database\\Console\\Migrations\\MigrateCommand->repositoryExists() #11 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(84): Illuminate\\Database\\Console\\Migrations\\MigrateCommand->prepareDatabase() #12 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(633): Illuminate\\Database\\Console\\Migrations\\MigrateCommand->Illuminate\\Database\\Console\\Migrations\\{closure}() #13 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(104): Illuminate\\Database\\Migrations\\Migrator->usingConnection() #14 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Database\\Console\\Migrations\\MigrateCommand->handle() #15 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #16 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure() #17 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod() #18 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\\Container\\BoundMethod::call() #19 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\\Container\\Container->call() #20 /var/www/BookStack/vendor/symfony/console/Command/Command.php(326): Illuminate\\Console\\Command->execute() #21 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Console/Command.php(181): Symfony\\Component\\Console\\Command\\Command->run() #22 /var/www/BookStack/vendor/symfony/console/Application.php(1096): Illuminate\\Console\\Command->run() #23 /var/www/BookStack/vendor/symfony/console/Application.php(324): Symfony\\Component\\Console\\Application->doRunCommand() #24 /var/www/BookStack/vendor/symfony/console/Application.php(175): Symfony\\Component\\Console\\Application->doRun() #25 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(201): Symfony\\Component\\Console\\Application->run() #26 /var/www/BookStack/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle() #27 {main} [previous exception] [object] (PDOException(code: 1045): SQLSTATE[HY000] [1045] Access denied for user 'bookstack'@'doc.homelab.local' (using password: YES) at /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:65) [stacktrace] #0 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(65): PDO->__construct() #1 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(45): Illuminate\\Database\\Connectors\\Connector->createPdoConnection() #2 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php(24): Illuminate\\Database\\Connectors\\Connector->createConnection() #3 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(184): Illuminate\\Database\\Connectors\\MySqlConnector->connect() #4 [internal function]: Illuminate\\Database\\Connectors\\ConnectionFactory->Illuminate\\Database\\Connectors\\{closure}() #5 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php(1339): call_user_func() #6 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php(528): Illuminate\\Database\\Connection->getPdo() #7 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php(423): Illuminate\\Database\\Connection->getPdoForSelect() #8 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php(816): Illuminate\\Database\\Connection->Illuminate\\Database\\{closure}() #9 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php(783): Illuminate\\Database\\Connection->runQueryCallback() #10 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php(431): Illuminate\\Database\\Connection->run() #11 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php(401): Illuminate\\Database\\Connection->select() #12 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php(42): Illuminate\\Database\\Connection->selectFromWriteConnection() #13 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(165): Illuminate\\Database\\Schema\\MySqlBuilder->getTables() #14 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php(184): Illuminate\\Database\\Schema\\Builder->hasTable() #15 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(700): Illuminate\\Database\\Migrations\\DatabaseMigrationRepository->repositoryExists() #16 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(140): Illuminate\\Database\\Migrations\\Migrator->repositoryExists() #17 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Support/helpers.php(248): Illuminate\\Database\\Console\\Migrations\\MigrateCommand->Illuminate\\Database\\Console\\Migrations\\{closure}() #18 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(159): retry() #19 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(116): Illuminate\\Database\\Console\\Migrations\\MigrateCommand->repositoryExists() #20 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(84): Illuminate\\Database\\Console\\Migrations\\MigrateCommand->prepareDatabase() #21 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(633): Illuminate\\Database\\Console\\Migrations\\MigrateCommand->Illuminate\\Database\\Console\\Migrations\\{closure}() #22 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(104): Illuminate\\Database\\Migrations\\Migrator->usingConnection() #23 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Database\\Console\\Migrations\\MigrateCommand->handle() #24 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #25 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure() #26 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod() #27 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\\Container\\BoundMethod::call() #28 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\\Container\\Container->call() #29 /var/www/BookStack/vendor/symfony/console/Command/Command.php(326): Illuminate\\Console\\Command->execute() #30 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Console/Command.php(181): Symfony\\Component\\Console\\Command\\Command->run() #31 /var/www/BookStack/vendor/symfony/console/Application.php(1096): Illuminate\\Console\\Command->run() #32 /var/www/BookStack/vendor/symfony/console/Application.php(324): Symfony\\Component\\Console\\Application->doRunCommand() #33 /var/www/BookStack/vendor/symfony/console/Application.php(175): Symfony\\Component\\Console\\Application->doRun() #34 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(201): Symfony\\Component\\Console\\Application->run() #35 /var/www/BookStack/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle() #36 {main} "} ```
Hosting Environment
php 8.1 Linux, ngnix