How to configure elgg using postgresql?

Hi there!

I am new to elgg and I was wondering if postgresql works with elgg. I've tried changing the port in the settings.php to 5432 since that's the port where my local psql responds to. Here's part of the settings in my settings.php:

$CONFIG->dbuser = 'dbuser';
$CONFIG->dbpass = 'dbpassword';
$CONFIG->dbname = 'dbname';
$CONFIG->dbhost = 'localhost';
$CONFIG->dbport = '5432';
$CONFIG->dbprefix = 'project_';
$CONFIG->dbencoding = 'utf8mb4';

I've tried changing the port to 3306 for mysql and it works. It doesn't seem to work for postgresql.

Probably there are stuff I need to add or modify. What is the usual setup for the settings.php for postgresql?

  • Elgg officially supports MySQL and nothing else. By own experience I can say that MariaDB also works. But I don't think Postgres will work - at least not out of the box.

    There are some discussion threads - many years old (pre-Elgg 2) - that clearly say it will definitely not work. With Elgg 2 a database abstraction layer was introduced that probably would make it possible to use Postgres. But please don't ask me how. And it will definitely not be as simple as making some trivial changes in settings.php! My suggestion: use MySQL or MariaDB and it works.

  • As iionly mentioned only MySQL is officially supported. WIth the database abstraction layer it should be possible to also use PostgreSQL but try at your own risk.

    Try changing https://github.com/Elgg/Elgg/blob/3.3/engine/classes/Elgg/Application.php#L657 and https://github.com/Elgg/Elgg/blob/3.3/engine/classes/Elgg/Database.php#L151

    I don't know the correct values for PostgreSQL, please be careful ;)

  • Thank you for all of your advise. I will try changing what you mentioned, Jerome. If it doesn't go well, I'll stick to MySQL. Thanks again iionly and Jerome!

  • Just an update. The modifying of the files doesn't work. Here's the lines I've changed:

    Line 657 of Application.php(as stated above)

    "adapter" => "pgsql",

    Line 151 of Database.php(as stated above)

    'driver' => 'pgsql',

    also tried

    'driver' => 'pdo_pgsql',

    It results to: Fatal error in exception handler. Check log for Exception at time 1594642615

    Since the files are part of the elgg directory in vendor, not a good idea to modify. Will be overwritten when it gets updated.

     

    Conclusion: Will stick to MySQL.

     

    Thank you, this is such a good learning experience *thumbs up*

  • It results to: Fatal error in exception handler. Check log for Exception at time 1594642615

    Just curious to know - what's in your server error log?

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking