Correct way to install psql without full Postgres on macOS?

You could also use homebrew to install libpq. brew install libpq This would give you psql, pg_dump and a whole bunch of other client utilities without installing Postgres. Unfortunately since it provides some of the same utilities as are included in the full postgresql package, brew installs it “keg-only” which means it isn’t in the … Read more

Postgresql: Scripting psql execution with password

You may wish to read a summary of the ways to authenticate to PostgreSQL. To answer your question, there are several ways provide a password for password-based authentication: Via the password prompt. Example: psql -h uta.biocommons.org -U foo Password for user foo: In a pgpass file. See libpq-pgpass. Format: <host>:<port>:<database>:<user>:<password> With the PGPASSWORD environment variable. … Read more

psql – save results of command to a file

From psql’s help (\?): \o [FILE] send all query results to file or |pipe The sequence of commands will look like this: [wist@scifres ~]$ psql db Welcome to psql 8.3.6, the PostgreSQL interactive terminal db=>\o out.txt db=>\dt Then any db operation output will be written to out.txt. Enter ‘\o’ to revert the output back to … Read more

Alternate output format for psql

I just needed to spend more time staring at the documentation. This command: \x on will do exactly what I wanted. Here is some sample output: select * from dda where u_id=24 and dda_is_deleted=’f’; -[ RECORD 1 ]——+—————————————————————————————————————————————————————————————————————- dda_id | 1121 u_id | 24 ab_id | 10304 dda_type | CHECKING dda_status | PENDING_VERIFICATION dda_is_deleted | … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)