Home > postgresql > Up and running with PostgreSQL

Up and running with PostgreSQL

Up and running with PostgreSQL

1. Install

sudo apt-get install postgresql-9.3

2. Set a password to the postgres user

$ sudo -u postgres psql postgres
psql (9.3.10)
Type "help" for help.

postgres=# \password postgres
Enter new password:
Enter it again:
postgres=# \q

3. Create a new role

$ sudo -u postgres createuser -D -A -P mynewuser
Enter password for new role:
Enter it again:

4. Create a database using the new role

$ sudo -u postgres createdb -O mynewuser mynewdatabase

5. Connect to new database using new role

psql -h 127.0.0.1 -p 5432 mynewdatabase mynewuser
Password for user mynewuser:
psql (9.3.10)
SSL connection (cipher: DHE-RSA-AES256-GCM-SHA384, bits: 256)
Type "help" for help.

mynewdatabase=> \q

6. Manual for createuser command

man createuser

Source:
https://help.ubuntu.com/community/PostgreSQL
http://www.postgresql.org/docs/current/static/app-createuser.html
http://www.postgresql.org/download/linux/ubuntu/

Advertisements
Categories: postgresql

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: