Create postgres user on Ubuntu

So, I installed postgresql9.3 on Ubuntu. Now I have to create a new user. Thus, anything is possible with the help of postgres superuser. But I need every new db to be a new user.

So what I did:

sudo -u postgres psql CREATE USER python with PASSWORD 'python'; CREATE DATABASE dbpython; GRANT ALL PRIVILEGES ON DATABASE dbpython to python; 

I also changed the / etc / postgresql / 9.1 / main / pg_hba.conf file and changed the local frompeer authentication option to md5.

After restarting postgres, I want to use a new user:

 ubuntu@ip-172-31-33-139 :~$ su python No passwd entry for user 'python' 

But

 ubuntu@ip-172-31-33-139 :~$ sudo service postgresql restart * Restarting PostgreSQL 9.3 database server [ OK ] ubuntu@ip-172-31-33-139 :~$ psql -d dbpython -U python Password for user python: psql (9.3.6) Type "help" for help. dbpython=> 

Why does this work, but su python is not? Important note: I am not creating a new python user in my Ubuntu, I hope this is not necessary for every new user in postgres.

+7
sql postgresql ubuntu
source share
1 answer

You mix the PostgreSQL user and the UNIX user, which is completely different.

 CREATE USER python with PASSWORD 'python'; 

This command creates a PostgreSQL user and does not create a UNIX user; you can verify it by listing the users in the /etc/passwd .

If you also want to use the UNIX user, you will have to create it yourself (or create a script).

+11
source share

All Articles