Download PostgreSQL binnary
https://www.enterprisedb.com/download-postgresql-binaries
PostgreSQL configuration
https://git-maspaad.blogspot.com/2020/12/how-to-start-stop-and-check-status.html
https://git-maspaad.blogspot.com/2024/11/tutorial-install-postgresql-on-linux.html
- - - - - - - - - - - - - - - - - - - - - - - - -
InitDB (first time only)
$ pg_ctl initdb -D "..\data" (enter)
Register PostgreSQL as windows service
$ pg_ctl register -N PostgreSQL-v9-p5433 -D "..\data"
Create user "postgres" (first time only)
$ createuser --port=5433 -s postgres
https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist
- - - - - - - - - - - - - - - - - - - - - - - - -
Cek status db
$ pg_ctl status -D "..\data" (enter)
Stop database
$ pg_ctl stop -D "..\data" (enter)
Run/Start database
$ pg_ctl start -D "..\data" (enter)
- - - - - - - - - - - - - - - - - - - - - - - - -
Connect to PostgreSQL using cmd (general)
$ psql --host=127.0.0.1 --port=5432 --username=postgres --password --dbname=db_example
Connect to PostgreSQL using cmd (by pass access)
$ psql --host=127.0.0.1 --port=5432 --username=postgres
Change Password PostgreSQL
$ ALTER USER postgres WITH PASSWORD 'Jakarta098';
Restart service PotsgreSQL on windows.
- - - - - - - - - - - - - - - - - - - - - - - - -
Backup Database PostgreSQL to .sql File
$ psql --verbose --host=127.0.0.1 --port=5432 --username=postgres --password --dbname=db_example --format=p --encoding=UTF-8 --inserts --no-privileges --no-owner --file D:\database\postgresql\db_example.sql -n "public" db_example
Restore .sql File to Database PostgreSQL
$ psql --host=127.0.0.1 --port=5432 --username=postgres --password --dbname=db_example < D:\database\postgresql\db_example.sql
- - - - - - - - - - - - - - - - - - - - - - - - -
Source :
https://stackoverflow.com/questions/19674456/run-postgresql-queries-from-the-command-line
https://stackoverflow.com/questions/40632228/input-file-appears-to-be-a-text-format-dump-please-use-psql
https://git-maspaad.blogspot.com/2024/11/tutorial-install-postgresql-on-linux.html
https://stackoverflow.com/questions/14484652/register-and-run-postgresql-9-0-as-windows-service
Comments
Post a Comment