postgresql connect with specify db if 'postgres' does not work

Backport to `stable5` of #3684
> Hi, 
> here is my attempt to fix #675 
> the thing is basicaly that we try to connect to 'postgres' db wich is a "protected" db... 
> from local there is no trouble but from a remote location the postgres db is often no accessible...
> so the install fail...
>
> here i change small things to connect to the specified db if the postgres fail
>
> :)

cc @eMerzh @Kondou-ger @DeepDiver1975 @bartv2 @karlitschek