PostgreSQL connect to database using psql
To connect to the PostgreSQL database server using psql command line, run If you have a PostgreSQL user and password, you can…
To connect to the PostgreSQL database server using psql command line, run If you have a PostgreSQL user and password, you can…
When i restart postgresql, i get following error postgres@vmi465483:~$ systemctl restart postgresql.service Failed to restart postgresql.service: The name org.freedesktop.PolicyKit1 was not provided…
To run PostgreSQL on docker, create a directory for saving the data presistant mkdir -p /opt/my-postgresql run docker container docker run –name…
To export a table into CSV file, run \copy TABLE_NAME to ‘FILE_NAME.csv’ csv header; This will save the CSV file in current…
To list all databases in the PostgreSQL database, first connect to the PostgreSQL database using psql command Now run This will list…
To create a database, run CREATE DATABASE “DB_NAME_HERE”; Creating user, grant permissions CREATE USER USER_NAME_HERE WITH PASSWORD ‘BAPT788HZutBdV’; GRANT ALL PRIVILEGES ON…
To delete a PostgreSQL database, run DROP DATABASE DB_NAME; Example DROP DATABASE “odoodb2”;
To backup PostgreSQL database, run Example If you don’t have PostgreSQL installed, you can use docker, pull the appropriate version of docker…
Method 1 To create user, become user “postgres” with su – postgres now run createuser USER_NAME Method 2 You can run following…
pg_ctl is used to start and stop the PostgreSQL server. To start PostgreSQL, run You can also use stop/restart. Back to PostgreSQL
psql commands \l List databases \l+ List databases \c DB_NAME connect to a database \du list users \dt list tables \d TABLE_NAME…