I’m usually using mysql, today for a test i had to use Postgres. I’m fairly happy how smooth everything went, as it was mainly verifying a database creation and setup. Here the little things I needed to do.
- download and install Postgres.app. I won’t use postgres regularly and I don’t want to have it autostarting or deeply integrated in my system.
- add postgress path to ~/.profile, all you need is export PATH=/Applications/Postgres.app/Contents/MacOS/bin:$PATH. Otherwise an older, macos-native postgres client will be used.
- open postgres console from terminal using psql -h localhost
- create user create user <usr> WITH password ‘<pwd>’ CREATEDB;
- make user super user alter user <usr> with superuser;
- list existing databases \list
- drop a database drop database <db>;
- in case of error: “ERROR: database “<db>” is being accessed by other users”
- run select procpid from pg_stat_activity where datname=’<db>‘; to get a list of process ids that are accessing the database.
- in terminal run kill <pid> for all processes out of the list provided by the statement above
- exit postgres console with \q.
This is all I need for my test environment.
Popularity: 10% [?]Tags: database, how-to, mac, postgres, test