1

I want to connect to my postgresql when running my python program. The issue i face is that my username is dave, but i can only access my database with the user postgres on linux. This constellation never failed me on my mac, because i could start postgres from my "dave" user account. With linux (ubuntu) i can only connect to the database with psql, when switching my user with *sudo -su postgres to the postgres user.

How am i able to start my program from my user dave while accessing the database?

David
  • 2,926
  • 1
  • 27
  • 61

1 Answers1

1

You'll have to create a user called dave:

  • Log on using sudo -u postgres
  • create database davedb;
  • create user dave with encrypted password 'testing';
  • grant all privileges on database davedb to dave;

Then, you can log in from your username itself like so:

psql dave davedb
--or--
psql -U dave -d davedb

If it asks you for your password, type it. You should be in then.

zedfoxus
  • 35,121
  • 5
  • 64
  • 63