BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
15.02k stars 1.88k forks source link

PHP db migration problem. #4098

Closed stustd closed 1 year ago

stustd commented 1 year ago

Attempted Debugging

Searched GitHub Issues

Describe the Scenario

On Ubuntu 22.04, manually installing Bookstack, I encounter a problem with 'php artisan migrate'. Apparently, the PHP SQL driver forgets to quote select strings, i.e (venv-knowhow uses php-8.0.27).

(venv-knowhow) knowhow@ax100:[BookStack]: php artisan migrate

                                                                                       APPLICATION IN PRODUCTION.                                                                                        

  Do you really wish to run this command? (yes/no) [no]
❯ yes

In Connection.php line 760:

  SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = actryx_knowhow_bookstack and table_name = migrations and table_type = 'BASE TABL  
  E')                                                                                                                                                                                                   

In Connector.php line 70:

  SQLSTATE[HY000] [2002] No such file or directory  

Trying out the proper SQL statement in mysql [MariaDB], I discovered that the quotes were missing around the search strings (actryx_knowhow_bookstack and migrations):

select * from information_schema.tables where table_schema = actryx_knowhow_bookstack and table_name = migrations and table_type = 'BASE TABLE';
ERROR 1054 (42S22): Unknown column 'actryx_knowhow_bookstack' in 'where clause'

Which should have been (note the quotes)

select * from information_schema.tables where table_schema = 'actryx_knowhow_bookstack' and table_name = 'migrations' and table_type = 'BASE TABLE')

Btw I have the same problem with a docker install.

Your help will be much appreciated.

Exact BookStack Version

v23.02.1

Log Content

No response

PHP Version

8.0.27

Hosting Environment

Ubuntu 22.04

ssddanbrown commented 1 year ago

Apparently, the PHP SQL driver forgets to quote select strings

I wouldn't get to fixed upon this element, It's likely just due to how the queries are presented in log output, it does not reflect the exact data/communication with the MySQL database.

The SQLSTATE[HY000] [2002] No such file or directory error commonly occurs when the database is not accessible by BookStack (eg. Not running, not accessible over network, wrong port/host used).

What exactly is being used to manage the venv as suggested in the post, and where does the database exist in relation to the BookStack installation?

PHP Version 8.0.27

Unrelated, but it's probably better just using the Ubuntu 22.04 default (8.1) or use 8.2 if you can configure flexibly, so that you won't have to upgrade just in a years time (Assuming PHP is only used for BookStack in this environment).

stustd commented 1 year ago

I'm now using stock php (8.1.2) on Ubuntu 22.04 (... no venv anymore, which only redirected to php 8.0.27, ... which I tried as that's the one mentioned in the Manual Install guide). Further, user (root) has db access from knowhow account. Now, php artisan migrate gives:

knowhow@ax100:~/src/bookstack/repo/BookStack$ php artisan migrate
PHP Warning:  Missing arginfo for Sass::compile_file() in Unknown on line 0

                                                                  APPLICATION IN PRODUCTION.                                                                  

  Do you really wish to run this command? (yes/no) [no]
❯ yes

   INFO  Nothing to migrate.  

knowhow@ax100:~/src/bookstack/repo/BookStack$

... still a problem...

stustd commented 1 year ago

Ok, making progress; now a Symphony exception in the browser: image

ssddanbrown commented 1 year ago

@stustd That indicates a potential permission issue. Check the web-server has the ability to write to the required locations: https://www.bookstackapp.com/docs/admin/filesystem-permissions/

I have no idea where the previous Missing arginfo for Sass::compile_file() warning is coming from though.

stustd commented 1 year ago

Indeed: bootstrap/cache needed +x permission for nginx. Thanks.

ssddanbrown commented 1 year ago

Will therefore close this off.

LHBL2003 commented 6 months ago

I had a similar message during the update and found this similar entry in the google search. I had to run the following command: "sudo apt install php-mysql"

This error was then corrected with "php artisan migrate".

In Connection.php line 760:

  could not find driver (SQL: select * from information_schema.tables where t  
  able_schema = bookstack and table_name = migrations and table_type = 'BASE   
  TABLE')                                                                      

In Connector.php line 70:

  could not find driver  

Maybe it will help someone if he finds the problem here.