Monday, June 29, 2009

Accessing PostgreSQL on CLI

The command line interface (CLI) of PostgreSQL is called "psql". To access the PostgreSQL server, issue the following commands:

# su postgres
$ psql

The first command is to shift from the "root" user to the "postgres" user. PostgreSQL does not allow "root" login. Instead, it uses the "postgres" user as the default administrator of the system.

The second command is to invoke the "psql" CLI under the user "postgres".

The following is the screen example of the above-mentioned command.

root@asus:/etc/init.d# su postgres
postgres@asus:/etc/init.d$ psql
Welcome to psql 8.3.7, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

postgres=#


Given the psql, you can now create databases and users.

No comments: