postgresql notes
tutorials
- PostgreSQL – Installing PostgreSQL Without Admin Rights on Windows
- Install PostgreSQL 14 Without Admin Rights on Windows 11 OS
installed version: 17.2
installation path: C:\Users\{user}\AppData\Roaming\pgsql\
following the tutorials from start to finish and got to make it work and connect to the node js project with the pg package from npm.
⚠️ not to be confused with the postgres package, which i made the mistake of installing at first. pg and postgres are 2 different npm packages.
opening pgAdmin4
desktop:
- Navigate to this path:
C:\Users\{user}\AppData\Roaming\pgsql\pgAdmin 4\runtime
- run
pgAdmin4.exe
web: How to access PgAdmin4 in web browser?
connecting to the database
const client = new Client({
user: 'dbuser',
password: 'secretpassword',
host: 'database.server.com',
port: 3211,
database: 'mydb',
})
await client.connect()
console.log(await client.query('SELECT NOW()'))
await client.end()
snippet from the pg documentation
the next day
after turning off the pc and working on postgres the next day - say i've done all the steps in the tutorial yesterday and was satisfied with making it work - don't forget to restart the server again.
- locate the database server path under the installation folder
example: C:\Users\{username}\AppData\Roaming\pgsql\mydata
where "mydata" is the database server name
- run the
pg_ctl
command on the terminal
pg_ctl -D "C:\Users\{username}\AppData\Roaming\pgsql\mydata" -l logfile start
after this, the database is now up and can be accessed again.
- used git bash terminal for all the commands mentioned here.