Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iXob1-0005qh-1D for pgsql-general@arkaria.postgresql.org; Thu, 21 Nov 2019 15:42:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iXoaz-00062y-Ml for pgsql-general@arkaria.postgresql.org; Thu, 21 Nov 2019 15:42:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iXoaz-00062r-Cc for pgsql-general@lists.postgresql.org; Thu, 21 Nov 2019 15:42:13 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iXoaw-0003Va-J0 for pgsql-general@postgresql.org; Thu, 21 Nov 2019 15:42:13 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 204F1AE8; Thu, 21 Nov 2019 10:42:08 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 21 Nov 2019 10:42:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=z STskHuK0KweLAHWMEiZ6Y95Jy7c1RrFwWdJxLzCG6M=; b=CsRRCNh/hwAjY/una rKUcJSINk+OsdglMa8pcBXkSs0v3gDDzgl8eMHSzNOG9gU6LbqMnkrPaCis1TnMN LYTKGHW81wmAvMhQ/R+PREGNrfXZOMoqzuiO9nEdX7PRAkkDImW+VW2aln3pDm4x IC5n3FXfaXp6p8fp6mWvD2CFmOeS/CRwcgcGO/194jQdqFdETCR3KpSRcNZmuxv+ h07nNuSlydDXHBM8ElmRxv7/a7/b9TsKsXovafSZ16D6SoFtfFjrA0Ykq2bDoaBl 2yKQFmNp8upoARHZIbZrH9LgncVesbjv9NxOk32GWCH2fUsZoEc4J+ulTPk1PGB7 /d+OQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=zSTskHuK0KweLAHWMEiZ6Y95Jy7c1RrFwWdJxLzCG 6M=; b=JVRu1fL92eKiS5mUm3gs01iQTmf1mmoFB531zkhdMU/SfB5uGuzqcgI5Z rAYbXOEUtfaqcOF7ZCmmx4I+sMPhtvHuPFqNd5EZPTIF4aXTF4OfL/uAsaRi8xaC QI9CiijmIjsUsk0Xabmvox2Bhzl03OlLxoqN4p/clDVx9EqEfb2eHt8Lj9zeCRAO 1RFr6IMMbpXziC10YQib8U8jSjMm9Ln0azXH8oa85TOT5W+S+UFyAcOcMbo0kujs Dy4V5anwXZduLEodlG8rIFs9sQZD+HB/CLBI72sqoyUxlkwh/RoDXsXIbgiesAez gcDoTi/DHWVjohiHw6p8ySPiSm5Ew== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudehvddgkeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvfhfhffkffgfgggjtgfgsehtke ertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecukfhppeejuddrvdduvddrudeffedrud dukeenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghk lhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.2] (unknown [71.212.133.118]) by mail.messagingengine.com (Postfix) with ESMTPA id DB3ED80065; Thu, 21 Nov 2019 10:42:06 -0500 (EST) Subject: Re: Tablespace setup issue To: =?UTF-8?Q?S=c3=a9bastien_Bihorel?= , pgsql-general@postgresql.org References: From: Adrian Klaver Message-ID: <3acb33cb-1c1d-5270-50a2-e0c9905315fb@aklaver.com> Date: Thu, 21 Nov 2019 07:42:06 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/21/19 6:48 AM, Sébastien Bihorel wrote: > Hi, > > I am new to this list and reaching out because I am having troubles > setting up a local PostgreSQL database on my laptop. Maybe, as a > preamble, I should say that I am pretty much a novice trying to teach > myself and get practical experience about database and SQL queries (I > have some general idea about relational DB structure and operation but > no actual experience creating a DB or writing SQL queries). > > Some background about my setup: > - OS: my laptop runs Linux Mint 19.1 (a flavor of ubuntu 18.04); psql > 12.1 was installed along with pgadmin 4. There is a single user (ie, > sebastien) on this machine and the group postgres exists. > - database: I have successfully created the new superuser sebastien >                                    List of roles >  Role name |                         Attributes > | Member of > -----------+------------------------------------------------------------+----------- >  postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS > | {} >  sebastien | Superuser, Create DB >  +| {} >            | Password valid until infinity                              | > > I have also successfully created a database (sebastien) for the new > superuser sebastien, and a schema (test) within this database. > > Now, I would like to assign a particular disk location for the > tablespace used by this database but I am getting all kinds of errors > apparently linked to folder permissions. > > The location is /home/sebastien/data/pgdata96_sebastien has the > following properties: > > /home/sebastien/data $ ls -l > drwxr-xr-x 2 sebastien postgres 4096 Nov 19 09:14 pgdata96_sebastien > > Starting psql as sebastien, I tried the following requests and got the > following errors: > > sebastien=# CREATE TABLESPACE sebdata LOCATION > '/home/sebastien/data/pgdata96_sebastien'; > ERROR:  could not set permissions on directory > "/home/sebastien/data/pgdata96_sebastien": Permission denied > sebastien=# ALTER DATABASE sebastien set TABLESPACE > '/home/sebastien/data/pgdata96_sebastien'; > ERROR:  syntax error at or near "'/home/sebastien/data/pgdata96_sebastien'" > LINE 1: ALTER DATABASE sebastien set TABLESPACE '/home/sebastien/dat... > > The manual states "The location must be an existing, empty directory > that is owned by the PostgreSQL operating system user." So, I am not > sure what I am doing wrong. Web searches ran on these error messages did > not enlighten me more... As it stands now the directory allows you(sebastien) writes on that directory. That is not the same as the Postgres system user, which I assume is postgres. You need to verify this and also who is part of postgres group and adjust the directory permissions to give the postgres system user full writes. The thing to remember is that the Postgres users(postgres, sebastien) are not the same as the system users even if they have the same name. > > I would greatly appreciated any pointers to reference material on these > issues or advises on how to approach this. > > Thank you in advance for your time. -- Adrian Klaver adrian.klaver@aklaver.com