SyntaxHighlighter

Wednesday, June 20, 2012

PostgreSQL - Creating a Database

PostgreSQL - Creating a Database

Great little reference over on 


How to setup a PostgreSQL database

Create the user


postgres@hostname:~$ createuser
Enter name of role to add: username
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
CREATE ROLE
postgres@hostname:~$

Create the db


postgres@hostname:~$ createdb databasename
CREATE DATABASE
postgres@hostname:~$

Grant Access


postgres@hostname:~$ psql
postgres=# alter user username with encrypted password 'password';
ALTER ROLE
postgres=# grant all privileges on database databasename to username;
GRANT
postgres@hostname:~$


No comments:

Post a Comment