Ebad Saghar
Ebad Saghar

Reputation: 1127

The default location of where Postgresql gets installed?

I was just trying to install Postgresql and Django. I'm looking to change the default database from sqlite to Postgresql (need to find it's bin to change some credentials), but I need to find the location of where Postgresql is installed. I did a normal download/install of it, but I forgot the location.

Is there a way to search for this using a command? Or is its path always default to where it gets installed?

Upvotes: 0

Views: 170

Answers (2)

Chris Montanaro
Chris Montanaro

Reputation: 18222

postgrsql appears to being found at /usr/lib/postgresql on my system, Ubuntu Wheezy.

create a user and assign ownership of the DB:

su - postgres

createuser -P  

createdb --owner [user_you_just_created] [db_name]

You can also use the postgres user, by default there is no password. To change the postgres user's password:

su - postgres

psql -U postgres

ALTER USER postgres with password 'my-secure-password';

Upvotes: 1

Alex
Alex

Reputation: 8539

You just need to change your DATABASES setting within your settings.py.

Change it to:

DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2', 
            'NAME': 'mydb', # Use whatever your database name is here
            'USER': 'myuser',
            'PASSWORD': 'password',
            'HOST': 'localhost', 
            'PORT': '', 
        }
    }

If you don't have a proper postgres database setup yet, then on your terminal type:

createdb mydb

This will create a new database named 'mydb'. You can change the name to whatever you want, just make sure you make it correspond in your settings.py.

Django docs on DATABASE setting here.

Upvotes: 3

Related Questions