Skip to content

Connecting to PostgreSQL the first time

Jennifer Scheuerell edited this page Mar 3, 2020 · 5 revisions

The first step of out tutorial is to connect to PostgreSQL as user postgres.

At your command prompt, input:

$ sudo su postgres
Password:

Provide your computer password.

At the next prompt:

$ psql
Password for user postgres: 

Provide the password you specified for user postgres when you installed PostgreSQL.

You should then see:

psql (11.1, server 10.0)  
Type "help" for help.

postgres=#

(Your version numbers in the parentheses following psql may be different.)
You are now connected to PostgreSQL using psql as the user postgres.

Next, create a database for the tutorial.

postgres=# create database tutorial;
CREATE DATABASE

And create a user for yourself.

postgres=# create user xxx password 'yyy';
CREATE ROLE
postgres=# ALTER USER xxx with superuser;
ALTER ROLE

Last, exit the connection as postgresql

postgres=# \q

Clone this wiki locally