Re: Nvim as external editor in psql as Postgres root user - .vimrc (environment?) issue

From: "Victoria Stuart (VictoriasJourney(dot)com)" <mail(at)VictoriasJourney(dot)com>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Cc: mail(at)VictoriasJourney(dot)com
Subject: Re: Nvim as external editor in psql as Postgres root user - .vimrc (environment?) issue
Date: 2018-03-16 21:17:07
Message-ID: 20180316141707.1764d238@VictoriasJourney.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

@Adrian: Good point!! ;-)

When I re-installed postgres some months ago, I basically followed

https://wiki.archlinux.org/index.php/PostgreSQL

https://serverfault.com/questions/601140/whats-the-difference-between-sudo-su-postgres-and-sudo-u-postgres

HOWEVER, as you note/allude, I tried this:

[victoria(at)victoria ~]$ pwd

/home/victoria

[victoria(at)victoria ~]$ createuser -s -U postgres --interactive

Enter name of role to add: victoria
createuser: creation of new role failed: ERROR: role "victoria" already exists

[victoria(at)victoria ~]$ createdb metab_test

createdb: database creation failed: ERROR: database "metab_test" already exists

[victoria(at)victoria ~]$ dropdb metab_test
[victoria(at)victoria ~]$ createdb metab_test

[victoria(at)victoria ~]$ psql -d metab_test -U victoria

psql (10.2)
Type "help" for help.

[metab_test]# \l
List of databases
┌─────────────┬───────────┬──────────┬─────────────┬─────────────┬───────────────────────┐
│ Name │ Owner │ Encoding │ Collate │ Ctype │ Access privileges │
├─────────────┼───────────┼──────────┼─────────────┼─────────────┼───────────────────────┤
│ metab │ postgres │ UTF8 │ en_US.UTF-8 │ en_US.UTF-8 │ │
│ metab_test │ victoria │ UTF8 │ en_US.UTF-8 │ en_US.UTF-8 │ │
│ metabolicdb │ metabolic │ UTF8 │ en_US.UTF-8 │ en_US.UTF-8 │ │
│ postgres │ postgres │ UTF8 │ en_US.UTF-8 │ en_US.UTF-8 │ │
│ template0 │ postgres │ UTF8 │ en_US.UTF-8 │ en_US.UTF-8 │ =c/postgres ↵│
│ │ │ │ │ │ postgres=CTc/postgres │
│ template1 │ postgres │ UTF8 │ en_US.UTF-8 │ en_US.UTF-8 │ =c/postgres ↵│
│ │ │ │ │ │ postgres=CTc/postgres │
└─────────────┴───────────┴──────────┴─────────────┴─────────────┴───────────────────────┘

[metab_test]# \c metab

You are now connected to database "metab" as user "victoria".

[metab]# \d
List of relations
┌────────┬───────────────────────────────┬──────────┬──────────┐
│ Schema │ Name │ Type │ Owner │
├────────┼───────────────────────────────┼──────────┼──────────┤
│ public │ bioent │ table │ postgres │
│ public │ bioent_id_seq │ sequence │ postgres │
│ public │ enzyme_synonyms │ table │ postgres │
│ public │ enzyme_synonyms_id_seq │ sequence │ postgres │
│ public │ glycolysis_enzymes │ table │ postgres │
│ public │ glycolysis_enzymes_id_seq │ sequence │ postgres │
│ public │ glycolysis_metabolites │ table │ postgres │
│ public │ glycolysis_metabolites_id_seq │ sequence │ postgres │
│ public │ metabolite_synonyms │ table │ postgres │
│ public │ metabolite_synonyms_id_seq │ sequence │ postgres │
│ public │ metabolites │ table │ victoria │
│ public │ metabolites_id_seq │ sequence │ victoria │
│ public │ relations │ table │ postgres │
│ public │ relations_id_seq │ sequence │ postgres │
└────────┴───────────────────────────────┴──────────┴──────────┘

[metab]# \e ## launches external editor (neovim), c. victoria's settings ...

[metab]# \q

[victoria(at)victoria ~]$

Of course (in Arch Linux), the postgres service enabled and running:

sudo systemctl enable postgresql
sudo systemctl enable postgresql

Thank you very much for your comment; this greatly simplifies things!

I guess I just needed a nudge in that direction.

Much appreciated! :-D

==============================================================================

----- Original Message(s): -----
Date: 2018 Mar 16 (Fri) 13:33
From: Adrian ...
Subject: Re: Nvim as external editor in psql as Postgres root user - .vimrc (environment?) issue

On 03/16/2018 01:06 PM, Victoria wrote:

> Ok, here is a clumsy solution.

Still not sure why you want to run as the system postgres user. The
system user postgres is not the same as the Postgres database user
postgres. It is just convention that the system user that Postgres runs
as is called postgres. If you want to work in Postgres as the database
user postgres you just need to supply -U postgres to the client(psql in
this case). You can do that from your home account(victoria) without all
the contortions below:)

[snip: my previous post / "solution"]

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-03-16 21:41:39 Re: Want to disable fully qualified table names on pg_dump in pg_dump (PostgreSQL) 9.6.8
Previous Message Foolish Ewe 2018-03-16 20:55:59 Re: Want to disable fully qualified table names on pg_dump in pg_dump (PostgreSQL) 9.6.8