LEARNING POSTGRESQL

OBJECT-RELATIONAL DATABASE SYSTEM
0

POSTGRESQL

MEDIUM

last hacked on Oct 29, 2017

PostgreSQL is an open-source object-relational database management system, developed at the University of California at Berkeley. # Installation sudo apt-get update sudo apt-get install postgresql postgresql-contrib # Roles User roles are integral to PostgreSQL for handling both authentication and authorization. ## Default User Role By default, PostgreSQL installs with user role `postgres`. To begin a PostgreSQL session the `postgres` user role, enter into terminal: $ sudo -i -u postgres $ psql To quit this session, enter into terminal: postgres=# \q ## Creating New Roles To create a new user role `david` and password `testpassword`, enter into terminal (while logged into a PostgreSQL session as user role `postgres`): postgres=# CREATE USER david WITH PASSWORD 'testpassword'; To list user roles, enter into terminal (while logged into a PostgreSQL session as user role `postgres`): postgres=# \du # Local PostgreSQL Server You may have to check your `postgres.conf` in `/etc/postgresql/9.6/main/` to verify connection settings (i.e. `listen_address` and `port`). To start a PostgreSQL server, enter into terminal: service postgresql start To stop a PostgreSQL server, enter into terminal: service postgresql stop To restart a PostgreSQL server, enter into terminal: service postgresql restart To view more argument options for `service postgresql`, simply enter into terminal: service postgresql # Documentation Sources * [PostgreSQL Official Docs](https://www.postgresql.org/) * Digital Ocean's [How To Install and Use PostgreSQL on Ubuntu 16.04](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-16-04) * [How To Backup PostgreSQL Databases on an Ubuntu VPS](https://www.digitalocean.com/community/tutorials/how-to-backup-postgresql-databases-on-an-ubuntu-vps) * [How to install PostgreSQL 9.6 on any Ubuntu version](https://askubuntu.com/questions/831292/how-to-install-postgresql-9-6-on-any-ubuntu-version) ## Help * [How To Use Roles and Manage Grant Permissions in PostgreSQL on a VPS](https://www.digitalocean.com/community/tutorials/how-to-use-roles-and-manage-grant-permissions-in-postgresql-on-a-vps--2) * [GRANT](https://www.postgresql.org/docs/9.0/static/sql-grant.html) * [Postgresql: password authentication failed for user “postgres”](https://stackoverflow.com/questions/7695962/postgresql-password-authentication-failed-for-user-postgres) * [How do I list all databases and tables using psql?](https://dba.stackexchange.com/questions/1285/how-do-i-list-all-databases-and-tables-using-psql) * [List the database privileges using psql](https://dba.stackexchange.com/questions/4286/list-the-database-privileges-using-psql)

COMMENTS







keep exploring!

back to all projects