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

I am trying to install Q2A in specific server. This server is the most major server in Japan. But, connection error occured.

Could not establish database connection. Please check the username, password and hostname in the config file, and if necessary set up the appropriate MySQL user and privileges.

The reason was that the server does not support mysqli. There are a lot of such a server. User should be able to select connection method by mysql (V1.6.x) and mysqli (for V1.7) in config.php.

Q2A version: 1.7

1 Answer

+1 vote
by
I fixed this issue by replacing qa-include/qa-db.php of V1.7 with qa-include/qa-db.php of V1.6.3. But, core developers would be necessary to take measures.
by
edited by
I have also thought it strange. However, without changing the basic settings of qa-config.php, I can connect database by changing qa-db.php to 1.6.3.
https://help.sakura.ad.jp/app/answers/detail/a_id/2105#ac06
by
!! Important !!
There was report from hosting provider. According to that report, mysqli is not supported in this host. This problem is very large. Many web users including Japan will not be able to use V1.7.
by
So is PDO supported in your host or not?

And have you tried connecting to mysqli in a standalone script? For example make a test.php with

    <?php
    $db = new mysqli('localhost', 'username', 'password', 'database');
    echo mysqli_connect_error();

Post the error message if you get one.
by
edited by
Thank you Scott. I re-tested by mounting your code in qa-config.php.

***** Code *****

<?php
define('QA_MYSQL_HOSTNAME', '**** host ****');
define('QA_MYSQL_USERNAME', '*** user ***');
define('QA_MYSQL_PASSWORD', '*** pw ***');
define('QA_MYSQL_DATABASE', '*** db ***');

echo '<html>'.PHP_EOL;
echo '<body>'.PHP_EOL;
echo '<h1>MySQLi test</h1>'.PHP_EOL;
echo '<h2>Create mysqli object</h2>'.PHP_EOL;
$db = new mysqli(QA_MYSQL_HOSTNAME, QA_MYSQL_USERNAME, QA_MYSQL_PASSWORD, QA_MYSQL_DATABASE);
echo '<h2>Connect result</h2>'.PHP_EOL;
echo '<pre>'.PHP_EOL;
echo 'db = '.print_r($db,true).PHP_EOL;
echo '</pre>'.PHP_EOL;
echo '<h2>Get connection status</h2>'.PHP_EOL;
$error = mysqli_connect_error();
if($error) {
    echo 'Error!!'.PHP_EOL;
    echo '<pre>'.PHP_EOL;
    echo 'error = '.print_r($error,true).PHP_EOL;
    echo '</pre>'.PHP_EOL;
} else {
    echo 'Success!!'.PHP_EOL;
}
echo '</body>'.PHP_EOL;
echo '</html>'.PHP_EOL;


***** Result *****

MySQLi test

Create mysqli object

Connect result

db = mysqli Object
(
    [affected_rows] => 0
    [client_info] => mysqlnd 5.0.10 - 20111026 - $Id: *************************************************** $
    [client_version] => 50010
    [connect_errno] => 0
    [connect_error] =>
    [errno] => 0
    [error] =>
    [error_list] => Array
        (
        )

    [field_count] => 0
    [host_info] => **** host **** via TCP/IP
    [info] =>
    [insert_id] => 0
    [server_info] => 5.5.38-log
    [server_version] => 50538
    [stat] => Uptime: 918372  Threads: 5  Questions: 94327756  Slow queries: 8  Opens: 136585  Flush tables: 1  Open tables: 19200  Queries per second avg: 102.711
    [sqlstate] => 00000
    [protocol_version] => 10
    [thread_id] => 3415302
    [warning_count] => 0
)

Get connection status

Success!!

***** My consideration *****

MySQLi connection is succeed. . .
My test of Q2A installation might have been insufficient...????
I would try a little more debug Q2A installation process.
...