martyfenwick
martyfenwick

Reputation: 11

Fatal error: Uncaught dml_exception: Table "config" does not exist when setting up Moodle 3.1 for the first time

I am attempting to setup Moodle 3.1 for the first time on my local development environment.

When I enter the setup process I get the following error:

( ! ) Fatal error: Uncaught dml_exception: Table "config" does not exist in /Library/WebServer/Documents/moodle/lib/dml/moodle_database.php on line 621

( ! ) dml_exception: Table "config" does not exist in /Library/WebServer/Documents/moodle/lib/dml/moodle_database.php on line 621

I am using PostgreSql and have my database configured as below:

                                   List of databases
    Name     |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-------------+----------+----------+-------------+-------------+-----------------------
 moodle      | moodle   | UTF8     | en_AU.UTF-8 | en_AU.UTF-8 | 
 postgres    | martyfenwick | UTF8     | en_AU.UTF-8 | en_AU.UTF-8 | 
 template0   | martyfenwick | UTF8     | en_AU.UTF-8 | en_AU.UTF-8 | =c/martyfenwick          +
             |          |          |             |             | martyfenwick=CTc/martyfenwick
 template1   | martyfenwick | UTF8     | en_AU.UTF-8 | en_AU.UTF-8 | =c/martyfenwick          +
             |          |          |             |             | martyfenwick=CTc/martyfenwick
 testdb      | testdb   | UTF8     | en_AU.UTF-8 | en_AU.UTF-8 | 
(7 rows)

I created the database and DB user with the following commands:

createuser -SRDP moodle
createdb -E utf8 -O moodle moodle

When I created the user I chose a PW which I am using in my config.php below.

This is my config.php:

<?php  // Moodle configuration file

unset($CFG);
global $CFG;
$CFG = new stdClass();

$CFG->dbtype    = 'pgsql';
$CFG->dblibrary = 'native';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'moodle';
$CFG->dbuser    = 'moodle';
$CFG->dbpass    = 'mypasswordinhere';
$CFG->prefix    = 'mdl_';
$CFG->dboptions = array (
  'dbpersist' => 0,
  'dbport' => 5432,
  'dbsocket' => '',
);

$CFG->wwwroot   = 'http://moodle.dev';
$CFG->dataroot  = '/Library/WebServer/Documents/moodledata';
$CFG->admin     = 'admin';

$CFG->directorypermissions = 0777;

// Force a debugging mode regardless the settings in the site administration
@error_reporting(E_ALL | E_STRICT);   // NOT FOR PRODUCTION SERVERS!
@ini_set('display_errors', '1');         // NOT FOR PRODUCTION SERVERS!
$CFG->debug = (E_ALL | E_STRICT);   // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS!
$CFG->debugdisplay = 1;              // NOT FOR PRODUCTION SERVERS!

require_once(dirname(__FILE__) . '/lib/setup.php');

// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!

I've also tried running the install from the CLI with php admin/cli/install.php, but I then get this:

PHP Fatal error: Uncaught Error: Call to a member function is_temptable() on null in /Library/WebServer/Documents/moodle/lib/dml/pgsql_native_moodle_database.php:393

I'm at a loss to see what i'm doing wrong here and why I can't build my DB schema (which is currently empty).

Upvotes: 1

Views: 514

Answers (1)

marcocassisa
marcocassisa

Reputation: 402

You may want to try first to install the database first, through PHP cli. From the moodle directory, as root,

sudo -u www-data php admin/cli/install_database.php  --agree-license --adminuser=admin --adminpass=admin --fullname=mymoodle --shortname=shortmoodle --summary="moodle install" [email protected]

Be sure to set the variable max_input_vars

Upvotes: 0

Related Questions