CONNECT TO DB --> \c dbname

GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO user;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO user;
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public to user;


# Start console


CREATE USER username WITH PASSWORD 'password';
CREATE DATABASE owncloud TEMPLATE template0 ENCODING 'UNICODE';
ALTER DATABASE owncloud OWNER TO username;
GRANT ALL PRIVILEGES ON DATABASE owncloud TO username;

psql -U user -h 127.0.0.1 database


sudo su postgres
$ psql 

# Then lets setup `role` and create database for owncloud 

postgres=# CREATE ROLE owncloud ; 
postgres=# ALTER ROLE owncloud WITH PASSWORD 'myPassword' ;
postgres=# ALTER ROLE owncloud WITH LOGIN ;

postgres=# CREATE DATABASE owncloud ;
postgres=# ALTER DATABASE owncloud OWNER TO owncloud ;

postgres=# \list
postgres=# \q 

# Data directory

SHOW data_directory;