PostgreSQL connect to database using psql

PostgreSQL

To connect to PostgreSQL database server using psql command line, run

If you have a PostgreSQL user and password, you can use

Example

-W option is to force asking password. See PostgreSQL […]

Read More…

postgresql.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files

When i restart postgresql, i get following error

This is because you are running the command as user postres. Login as user “root”, you will be able to restart postgres with command

See PostgreSQL […]

Read More…

PostgreSQL List all databases

PostgreSQL

To list all databases in PostgreSQL database, first connect to PostgreSQL database using psql command

Now run

This will list all available databases. To change to a database, use command /connect

Once you connected to a database, you can list all tables in a database with command

[…]

Read More…

PostgreSQL Create Database

To create a database, run

Creating user, grant permissions

Creating a User and Database using psql

[…]

Read More…