Quantcast

Django + Postgressql

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Django + Postgressql

Robert Dean
Hi,
 
 
I seem to be having problems configuring Postgres with Django and was wondering if someone could help me as I cant find any tutorials that fit my problem.
 
First, I seem to be having issues with my postgres permissions/or understand them.
 
Trying to connect to a database in root I get "psql: FATAL:  role "root" does not exist"
 
Also after trying this I get:
[hidden email] psql -d template1 -c "ALTER USER postgres WITH PASSWORD 'mypassword';"
could not change directory to "/root"
ALTER ROLE
[hidden email] createdb mytestdb
could not change directory to "/root"
createdb: database creation failed: ERROR:  source database "template1" is being accessed by other users
DETAIL:  There are 1 other session(s) using the database.
 
Can someone help me figure this out? Why can it not change directory to root and why is template1 being accesed by another user?
 
Thanks in advance
 
Rob
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Django + Postgressql

SUNDAY A. OLUTAYO
You do not need to be a root to login nor create sys account for postgres just switch user to postgres e.g
sudo -u postgres psql template1

The template1 could an exiting db you are login into, it a default template you use before create a user db.

Sunday Olutayo

 
 
I seem to be having problems configuring Postgres with Django and was wondering if someone could help me as I cant find any tutorials that fit my problem.
 
First, I seem to be having issues with my postgres permissions/or understand them.
 
Trying to connect to a database in root I get "psql: FATAL:  role "root" does not exist"
 
Also after trying this I get:
[hidden email] psql -d template1 -c "ALTER USER postgres WITH PASSWORD 'mypassword';"
could not change directory to "/root"
ALTER ROLE
[hidden email] createdb mytestdb
could not change directory to "/root"
createdb: database creation failed: ERROR:  source database "template1" is being accessed by other users
DETAIL:  There are 1 other session(s) using the database.
 
Can someone help me figure this out? Why can it not change directory to root and why is template1 being accesed by another user?
 
Thanks in advance
 
Rob
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Django + Postgressql

Tom Lane-2
In reply to this post by Robert Dean
Robert Dean <[hidden email]> writes:
> postgres@myvps:/root$ psql -d template1 -c "ALTER USER postgres WITH PASSWORD 'mypassword';"
> could not change directory to "/root"

Dunno anything about django, but what this looks like is you logged in
as root and then did "su postgres" rather than "su - postgres".  So now
you're still in root's $HOME, but you can't read the current directory
for lack of permissions.  A lot of stuff will act a bit squirrelly in
that context, not only psql.  Use "su - postgres".  Better yet, create
another superuser named after your regular user account, so that you can
do Postgres stuff without going through root in the first place.

> createdb: database creation failed: ERROR:  source database "template1" is being accessed by other users
> DETAIL:  There are 1 other session(s) using the database.

"select * from pg_stat_activity" might tell you something about that.

                        regards, tom lane

--
Sent via pgsql-novice mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice

Loading...