Topic on Project:Support desk

upgrading mediawiki when using postgresql database on non-default port

5
Summary by PlavorSeol

Answered

Jeff.janes (talkcontribs)

I'm upgrading MediaWiki from 1.20.5 to 1.21.2 (or to 1_22wmf18, same issue), backed by Postgresql database.

MediaWiki	1.20.5
PHP	5.4.5 (apache2handler)
PostgreSQL	9.2.4

I've set $wgDBport to a non-default port.

I'm using the web update method. When it prompts for the wgUpgradeKey, I enter it. I got an error that it cannot connect, and asks Is the server running on host "foobar.example.local" (127.0.0.1) and accepting TCP/IP connections on port 5432?.

Note that 5432 is the default port for PostgreSQL, but is not the port I am using.

It then asks for the upgrade key again, which I provide again. This time, it works and the upgrade completes. Why does it ignore $wgDBport the first time I enter the upgrade key, but then accepts it the second time?

That is rather confusing. Worse, it might upgrade the wrong database if one were to have multiple wikis and multiple databases.

I tried to assess the behavior when using MySQL instead of PostgreSQL, but it appears that is not possible to use MySQL on a non-default port, so this does not apply there.

MarkAHershberger (talkcontribs)

Before I attempt to reproduce this, could you tell me if you're still having this problem? (Sorry for the month+ delay).

185.42.60.232 (talkcontribs)

This is really sad that I cant use different port instead but 5432, there is my LocalSettings.php configuration:

$wgDBtype = "postgres";

$wgDBserver = "127.0.0.1";

$wgDBport = 11111;

$wgDBname = "mydatabase";

$wgDBmwschema = "myscheme";

$wgDBuser = "postgres";

$wgDBpassword = "postgres";

Errors:

  • Cannot connect to database mydatabase: Cannot access the database: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?
  • Cannot connect to database template1: Cannot access the database: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?
  • Cannot connect to database postgres: Cannot access the database: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?
Makeev95 (talkcontribs)

I solved it by creating port link:

ln -s /var/run/postgresql/.s.PGSQL.$port /path/to/wiki/.s.PGSQL.5432

LocalSettings.php configuration:

$wgDBserver = "/path/to/wiki"

$wgDBport is blank

MarkAHershberger (talkcontribs)

Is that documented somewhere? It seems like it should be here.