Programming/PostgreSQL: Difference between revisions
Jump to navigation
Jump to search
Brodriguez (talk | contribs) (Update links) |
Brodriguez (talk | contribs) (Move basic "access shell" commands to this page) |
||
Line 2: | Line 2: | ||
It acts as an alternative to the common database [[Programming/MySQL|MySQL]]. | It acts as an alternative to the common database [[Programming/MySQL|MySQL]]. | ||
== Setup == | == Setup == | ||
* [[Programming/PostgreSQL/Setup | Setup]] | * [[Programming/PostgreSQL/Setup | Setup]] | ||
== Syntax == | == Syntax == | ||
* [[Programming/PostgreSQL/Databases | Databases]] | * [[Programming/PostgreSQL/Databases | Databases]] | ||
* [[PostgresQL/Queries | Queries]] | * [[PostgresQL/Queries | Queries]] | ||
== Basics == | |||
=== Accessing the PostgreSQL Shell === | |||
Access the PostgreSQL shell with: | |||
psql -U <user_name> -d <database_name> | |||
Exit the shell with: | |||
\q | |||
To access the PostgreSQL shell for the first time (prior to creating any additional users), invoke the {{ ic |postgres}} user: | |||
sudo -u postgres psql | |||
=== Accessing the Linux PostgreSQL Account === | |||
Sometimes (rarely), you'll want to access the actual Linux account made for PostgreSQL, rather than just the database user.<br> | |||
To do this, use: | |||
sudo -i -u postgres | |||
This is required for some commands, such as the [[Programming/PostgreSQL/Setup#Create User | createuser ]] linux terminal command. |
Revision as of 04:29, 20 November 2020
PostgreSQL is an open source object-relational database.
It acts as an alternative to the common database MySQL.
Setup
Syntax
Basics
Accessing the PostgreSQL Shell
Access the PostgreSQL shell with:
psql -U <user_name> -d <database_name>
Exit the shell with:
\q
To access the PostgreSQL shell for the first time (prior to creating any additional users), invoke the postgres
user:
sudo -u postgres psql
Accessing the Linux PostgreSQL Account
Sometimes (rarely), you'll want to access the actual Linux account made for PostgreSQL, rather than just the database user.
To do this, use:
sudo -i -u postgres
This is required for some commands, such as the createuser linux terminal command.