Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+8 votes
in Q2A Core by

First time I start running Q2A site but i got belows error in nginx error log:

2022/07/06 18:01:20 [error] 18996#22728: *7 FastCGI sent in stderr: "PHP Fatal error:  Uncaught mysqli_sql_exception: Table 'q2a_db.qa_options' doesn't exist in H:\nginx_test\nginx\qa\qa-include\qa-db.php:227
Stack trace:
#0 H:\nginx_test\nginx\qa\qa-include\qa-db.php(227): mysqli->query()
#1 H:\nginx_test\nginx\qa\qa-include\qa-db.php(202): qa_db_query_execute()
#2 H:\nginx_test\nginx\qa\qa-include\qa-db.php(557): qa_db_query_raw()
#3 H:\nginx_test\nginx\qa\qa-include\qa-db.php(590): qa_db_single_select()
#4 H:\nginx_test\nginx\qa\qa-include\app\options.php(135): qa_db_multi_select()
#5 H:\nginx_test\nginx\qa\qa-include\qa-base.php(403): qa_preload_options()
#6 H:\nginx_test\nginx\qa\qa-include\qa-page.php(36): qa_initialize_postdb_plugins()
#7 H:\nginx_test\nginx\qa\qa-include\qa-index.php(188): require('...')
#8 H:\nginx_test\nginx\qa\index.php(27): require('...')
#9 {main}
  thrown in H:\nginx_test\nginx\qa\qa-include\qa-db.php on line 227" while reading response header from upstream, client:, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://", host: ""

Obviously, it has successfully connected to the database service, but has not accessed the specified table.
It looks the site not create required table in database at first running.

What I do:
Configure the site according to "https://docs.question2answer.org/install/".
Start php-cgi.exe, start nginx.exe, access index.php
=> Got state code 500, got error above in error.log

What should I do?

Software version:
Q2A: 1.8.6
PHP: 8.1.8
nginx: 1.23.0
MySQL: 8.0.25

OS: windows 10

Q2A version: 1.8.6
1. Have you properly set the database configuration in qa-config.php file?
2. Does the user have the appropriate privileges? (e.g. CREATE, ALTER, etc)
3. Have other tables been created in the database?
4. If you do a fresh start with a different database and a more privileged MySQL user, do you get to the same result?
1. all confirmed. Note that the error message is "table not found" instead of "connection failed", which means it can successfully connect to the database..
2. it's "root" user.
3. it's empty database, and still empty after Q2A start running.
4. root is highest privilege user, other name database still not work well.
edited by

5. Aside from the database connection, have you changed anything else in qa-config.php? (e.g. QA_MYSQL_TABLE_PREFIX)
6. Have you added a new theme/plugin/language pack BEFORE installing Q2A? If so, please, retry with the ones distributed by the standard Q2A package
7. Does the setup succeed if you use Apache? (nginx is not really officially supported)
5. nope.
6. nope.
7. nope.
I just unpack Q2A, rename files ".htaccess" and "qa-config.php", set db config in "qa-config.php" and access "index.php". Then I got same error.
I'm tried debug it and noticed it won't enter the line:
./qa-inluced/qa-index.php line 178: require QA_INCLUDE_DIR . 'qa-install.php';
it looks I need a way to tell the site install Q2A and initialize database.

1 Answer

+4 votes
selected by
Best answer

It seems a default setting in PHP has changed in PHP 8.1. Now, MySQL errors throw exceptions by default. That is an issue if the SQL statement is not wrapped in a try/catch clause.

This change should revert the behavior back to the one prior to PHP 8.1.

It works well!
edited by
This is working for me too but with an error message.
Please have a look here https://www.question2answer.org/qa/105300/could-causing-error-after-successfully-installation-xampp
That is not related to this fix. That is a different error that this current error didn't even allow you to see