Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

CDbConnection failed to open the DB connection with Ubuntu, psql - new install

  • grylli
  • grylli's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 1 month ago #241661 by grylli
Please help us help you and fill where relevant:
Your LimeSurvey version: 5.5.0; $config = '5.5.0'; $config = 495; $config = 221219; $config = true; $config  = 3; $config = '30311'; Yii command runner (based on Yii v1.1.26);
Own server or LimeSurvey hosting: Own server. Ubuntu 22.10; Nginx 1.22.0-1ubuntu1.1; PHP 2:8.1+92ubuntu1
Survey theme/template: N/A
==================
(Write here your question/remark)

Followed [url] manual.limesurvey.org/Installation_-_LimeSurvey_CE [/url]  and [url] manual.limesurvey.org/Installation_using...e_interface_(CLI)/en [/url] - the command `php console.php install limeadmin ilikecycling Admin grylli@example.org` returns the following error

Connecting to database...
Could not connect to database: CDbConnection failed to open the DB connection.
Creating database...
GRYLLI GETTING CONNECTION STRING NOW
GRYLLI Connection string:
Opening connection...
CException: Invalid access data. Check your config.php db access data in /var/www/limesurvey/application/commands/InstallCommand.php:118
Stack trace:
#0 /var/www/limesurvey/application/commands/InstallCommand.php(51): InstallCommand->createDatabase()
#1 /var/www/limesurvey/vendor/yiisoft/yii/framework/console/CConsoleCommandRunner.php(71): InstallCommand->run()
#2 /var/www/limesurvey/vendor/yiisoft/yii/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run()
#3 /var/www/limesurvey/vendor/yiisoft/yii/framework/base/CApplication.php(185): CConsoleApplication->processRequest()
#4 /var/www/limesurvey/application/commands/console.php(77): CApplication->run()


Note the lines starting with GRYLLI are lines I added manually, for example in the following the 'getDb done' line is not printed:

            try {
                $this->output('Connecting to database...'); // this is printed ok
                $this->connection = App()->getDb();
                $this->output('GRYLLI - CONNECTED TO DB - getDb DONE'); // this is not printed
                $this->connection->active = true;
                $this->output('Using connection string ' . $this->connection->connectionString);
            } catch (CDbException $e) {
                $this->output('Could not connect to database: ' . $e->getMessage());
                $this->createDatabase();
            };

My php or postgres or nginx or limesurvey logs have not been enlightening about what's going on.

My config.php contains the following:

<?php if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
return array(
    'name' => 'LimeSurvey',
    'components' => array(
        'db' => array(
            'connectionString' => 'pgsql:host=localhost;port=5432;user=limesurvey;password=ilikecycling;name=limesurvey;',
            'emulatePrepare' => true,
            'username' => 'limesurvey',
            'password' => 'ilikecycling',
            'charset' => 'utf8',
            'tablePrefix' => 'lime_',
        ),

        'urlManager' => array(
            'urlFormat' => 'get',
            'rules' => array(
            // You can put your own rules here
            ),
            'showScriptName' => true,
        ),

    ),
    // Use the following config variable to set modified optional settings copied from config-defaults.php
    'config'=>array(
    // debug: Set this to 1 if you are looking for errors. If you still get no errors after enabling this
    // then please check your error-logs - either in your hosting provider admin panel or in some /logs directory
    // on your webspace.
    // LimeSurvey developers: Set this to 2 to additionally display STRICT PHP error messages and get full access to standard themes
        'debug'=>2,
        'debugsql'=>1, // Set this to 1 to enanble sql logging, only active when debug = 2
        // 'force_xmlsettings_for_survey_rendering' => true, // Uncomment if you want to force the use of the XML file rather than DB (for easy theme development)
        // 'use_asset_manager'=>true, // Uncomment if you want to use debug mode and asset manager at the same time
    )
);
/* End of file config.php */
/* Location: ./application/config/config.php */

I checked manually with 'psql -h localhost -U limesurvey -p 5432' and supplied the 'ilikecycling' password and it works fine, it shows a postgresql prompt.

The home page where the survey is supposed to be has the error 'Could not connect to database: CDbConnection failed to open the DB connection.' in large red letters.

Would be happy to go step by step through the code execution to see what's going on, like in gdb for C codes - tried reading manual.limesurvey.org/Debugging but found it too confusing.

Advice would be appreciated.

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose