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 1pNJyv-0000sY-Fx for pgsql-general@arkaria.postgresql.org; Wed, 01 Feb 2023 20:45:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pNJyu-0007Jl-DR for pgsql-general@arkaria.postgresql.org; Wed, 01 Feb 2023 20:45:24 +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 1pNJyu-0007JP-2F for pgsql-general@lists.postgresql.org; Wed, 01 Feb 2023 20:45:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNJys-0004F4-1i for pgsql-general@lists.postgresql.org; Wed, 01 Feb 2023 20:45:23 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 311KjJ7h1413384; Wed, 1 Feb 2023 15:45:19 -0500 From: Tom Lane To: Siddharth Jain cc: pgsql-general@lists.postgresql.org Subject: Re: FATAL: database "xxx" does not exist when it does In-reply-to: References: Comments: In-reply-to Siddharth Jain message dated "Wed, 01 Feb 2023 12:13:18 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1413382.1675284319.1@sss.pgh.pa.us> Date: Wed, 01 Feb 2023 15:45:19 -0500 Message-ID: <1413383.1675284319@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Siddharth Jain writes: > postgres=> \c xxx > psql (13.9 (Debian 13.9-0+deb11u1), server 14.4) > WARNING: psql major version 13, server major version 14. > Some psql features might not work. I wonder whether your problem is related to this version mismatch. I'm not entirely sure how that would happen, but older psql with newer server is certainly not a heavily-tested case. > i gave all privileges on xxx to user sysbench: > postgres=> GRANT ALL PRIVILEGES ON DATABASE xxx TO sysbench; [ squint... ] Your prompt indicates you are not superuser here. Is this really an accurate transcript of what you did? > sysbench=> \c xxx > FATAL: database "xxx" does not exist > Previous connection kept If I had to guess on the basis of this much info, I'd guess that there's more than one Postgres cluster on this machine, one of which now has an "xxx" database while another does not, and psql is somehow trying to connect to the latter one at this point. Possibly this has to do with the version mismatch; I'm not very sure offhand whether \c will preserve prior values for options like port number in this context. Especially if you are using version-mismatched psql and libpq, which seems moderately likely. regards, tom lane