Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sCdXx-006zSY-01 for pgsql-admin@arkaria.postgresql.org; Thu, 30 May 2024 11:02:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sCdXw-00388P-QB for pgsql-admin@arkaria.postgresql.org; Thu, 30 May 2024 11:02:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sCdXw-00388H-CH for pgsql-admin@lists.postgresql.org; Thu, 30 May 2024 11:02:12 +0000 Received: from mout-u-107.mailbox.org ([80.241.59.207]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sCdXo-002epS-4z for pgsql-admin@lists.postgresql.org; Thu, 30 May 2024 11:02:11 +0000 Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4Vqjxc6lqkz9sZc; Thu, 30 May 2024 13:01:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ewie.name; s=MBO0001; t=1717066917; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=CxMYGSKYy6OqCfI8KIll4v9rIEMECgpESmd/cYzD7TY=; b=RqFfuHmoX5RrXOFyEf2yMP5cQaS3xDVO/9098N4GVMMpxGIjfVY1uycd/2ybMKR34rFSZB WoAmeG6j/7m1lrO0PlN6xq/a81EPCBvDbJ7gRNo0G/6zAz/90adWlWKwWvnllSBhZIWcwt MI0SI2/Is6r+BWtrk7l3OilG7txIjdzQ8hbtHrJIby8GbDTYjxYKFJ5jfRuAUkt32p+e9O e7kuEkZHPzNOXZbLTDvKavzWOQb7M1g+WxAyU8Fa1b6QzSZmnHOpwqF0BrmX6bCovGaFA/ F1XM2ks+ZK/Ru3TdIddX8vVSPhEHCYbYmY7VxrqC4fJ/5yJn7mhkIcIL24eskA== Date: Thu, 30 May 2024 13:01:54 +0200 From: Erik Wienhold To: Edwin UY Cc: pgsql-admin@lists.postgresql.org Subject: Re: psql - prompt for password Message-ID: <822d3df1-9ec9-4cbb-922a-c7ac0cff424d@ewie.name> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-05-30 10:07 +0200, Edwin UY wrote: > Is createuser the only one I can use to create a user where it prompts for > a password? There is no alteruser though. > I want to use psql and \prompt but am lost on how to use it. > Basically just want to use it for running a psql script like for example - > ALTER USER spongebob WITH ENCRYPTED PASSWORD ':newpassword'; Or use \password which has the benefit of not leaking the plaintext password into the logs which would be the case if there's an error in the ALTER USER command. psql -c '\password spongebob' -- Erik