Search Postgresql Archives

Re:

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/15/2015 05:44 AM, Alex Luya wrote:
Ubuntu 14.04 64bit + postgresql 9.4 are used here;

What I have done are:

1,Sign In ubuntu by user alex

2,then:sudo -i -u postgres

3,then:psql jump into command client

Assuming -U postgres, correct?

4,then: create database icare;

5,then: \q jump out command client

6,then run: exit jump out psql

7,then pg_restore --clean --create --exit-on-error --dbname=icare
icare-test.tar

Assuming -U alex, correct?

So you CREATed the database as the user postgres.

You then tried to pg_restore as user alex.

The below says user alex does not have SCHEMA permissions on DATABASE icare.

To be clear, system users are not automatically database users, they are two different universes, though your CREATE DATABASE worked as postgres is a database user name. A mapping can be set up between them, but that is not the default. What this means is you do not have to switch system users to do things in Postgres, you just need to specify -U(--username) to your Postgres commands. That argument can also come from an environment variable(PGUSER http://www.postgresql.org/docs/9.4/interactive/libpq-envars.html). In the absence of either a command line argument or an environment variable the system user name will be used, though this will only work if that name is also a database user name.

So to get pass this problem when you do the pg_restore specify -U postgres:

pg_restore --clean --create --exit-on-error --dbname=icare -U postgres icare-test.tar



On Fri, Nov 13, 2015 at 10:52 PM, Giuseppe Sacco
<giuseppe@xxxxxxxxxxxxxxxxxxxxxxxxx
<mailto:giuseppe@xxxxxxxxxxxxxxxxxxxxxxxxx>> wrote:

    Hello,

    Il giorno ven, 13/11/2015 alle 13.38 +0800, Alex Luya ha scritto:
     > Hello,
     >        I created a new database by
     >        create database icare;
     >        then quit off psql and  run:
     >         pg_restore --clean --create --exit-on-error --dbname=icare
     > icare-test.tar
     >          it complains:
     >           pg_restore: [archiver (db)] Error while PROCESSING TOC:
     >           pg_restore: [archiver (db)] Error from TOC entry 21; 2615
     > 80924 SCHEMA icare icare
     >           pg_restore: [archiver (db)] could not execute query: ERROR:
     >  permission denied for database icare
     >            Command was: CREATE SCHEMA icare;

     From what I understand, it means that the postgresql user that is
    restoring the dump cannot create a schema on "icare" database. So, is
    that user the same that issued che "create database" earlier? If it's
    not, then you should grant all required priviledges to that user.

    Bye,
    Giuseppe


    --
    Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx
    <mailto:pgsql-general@xxxxxxxxxxxxxx>)
    To make changes to your subscription:
    http://www.postgresql.org/mailpref/pgsql-general




--
Adrian Klaver
adrian.klaver@xxxxxxxxxxx


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux