Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qFDP0-0000Kg-Ik for pgsql-general@arkaria.postgresql.org; Fri, 30 Jun 2023 12:39:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qFDOz-0000Bi-Fs for pgsql-general@arkaria.postgresql.org; Fri, 30 Jun 2023 12:39:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qFDOx-0000BZ-9L for pgsql-general@lists.postgresql.org; Fri, 30 Jun 2023 12:39:05 +0000 Received: from rs6162.luxsci.com ([162.142.76.255]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qFDOs-001MV7-SK for pgsql-general@lists.postgresql.org; Fri, 30 Jun 2023 12:39:01 +0000 Received: from pfortin.com (h231.250.89.75.dynamic.ip.windstream.net [75.89.250.231]) (authenticated bits=0) by rs6162.luxsci.com (8.15.2/8.14.9) with ESMTPSA id 35UCcsqE562127 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 12:38:54 GMT Date: Fri, 30 Jun 2023 08:38:54 -0400 From: pf@pfortin.com To: pgsql-general@lists.postgresql.org Subject: Re: psql and pgpass.conf on Windows Message-ID: <20230630083854.1668913d@pfortin.com> In-Reply-To: <20230630031636.jot6q5v77dlinlro@jrouhaud> References: <20230629224200.080cc1a4.pfortin@pfortin.com> <20230630031636.jot6q5v77dlinlro@jrouhaud> X-Mailer: Claws Mail 4.1.1git47 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Lux-Comment: Message 35UCcsqE562127 sent by user #22429 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pfortin.com; h=date:from:to:subject:message-id:in-reply-to:references:mime-version:content-type:content-transfer-encoding; s=dkim; bh=rnyVxue4uP/eVuggZit8H/77B1WO2gx7A/UOGqcProQ=; b=j3nabnNbZkbB/lPgXx0BM7MfOVZOij70mU4mmYbTTgDM0lcj8relvqhUtH/LEaiVcbY3/lM0yQgyTaV2blmumx+0a0zjMzoVIpCGC7SL+i8/Jl9nJKG1NV+Zx0zddBvZWpTeqdTdasksu7R5Qg4GXkaZfyNkuv/kta4W0r5RgbQ= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 30 Jun 2023 11:16:36 +0800 Julien Rouhaud wrote: >Hi, > >On Thu, Jun 29, 2023 at 10:42:00PM -0400, pf@pfortin.com wrote: >> >> Windows: %APPDATA%\postgresql\pgpass.conf >> >> On Linux, this works. However, on Windows, psql will not read >> pgpass.conf (tried in just about every location I could think of) >> >> Even: "set PGPASSFILE=" does not work. >> >> Finally, out of frustration, tried: >> set PGPASSWORD= >> and that got me past the password issue, only to now get: >> 'more' is not recognized as an internal or external command, >> operable program or batch file. >> >> Given the number of queries about pgpass.conf and finding no answer that >> works, is there no bug report on this? >> >> Thinking that psql was not adjusted for Windows, tried naming the file: >> .pgpass >> .pgpass.conf >> also in various locations to no avail... >> What am I (and all the others found in searches) missing? Or are there >> unresolved bugs in psql? >> - pgpass.conf >> - expecting external executable: 'more' > >The file should indeed be by default %APPDATA%/postgresql/pgpass.conf, Will have to check with the owner of that machine where the PG install came from... maybe a non-official installer...? >and it's known to be functional on Windows. Given the number of searches we've done, at least one "Success" message should have been found; alas... >The fact that you hit some error with a "more" program makes me think that your >script setup some environment variables (like PAGER=more, which would explain >why you hit that error) that maybe interfere with file location and/or name. Good point; but... echo %PAGER% %PAGER% (does Windows normally print var name if empty? I'm a Linux-only user since 1998) ...apparently, it does: echo %JUNK% %JUNK% ;p vs: echo %APPDATA% C:\Users\Pierre\AppData\Roaming >Now, since setting PGPASSFILE also doesn't work I start to wonder if there's >another problem. Does the password (or any other field) contain some non-ASCII >characters? type %APPDATA%\postgresql\pgpass.conf 127.0.0.1:5432:ncsbe:postgres: (only ASCII characters and no trailing space) was using "localhost" before trying 127.0.0.1 even "*:*:..." failed. >There could be an encoding issue in the file, or maybe the problem >is with the presence or absence of a BOM in the file. Another thing you should >try just in case is to replace backwards slashes with forward slashes. No [back]slashes at all (except in later testing with PGPASSFILE...but psql should be looking in the right place without hinting... >If none of that work, you could also check what file psql is trying to open >using the equivalent of "strace" for Windows, if such a thing exists. LOL Knowing it wouldn't work, I actually typed "strace"... to see if psql was accessing the file, I tried changing the port number; but psql still mentions 5432 in its error message. Thanks, will do more digging when I return, Pierre