Psql could not connect to server: No such file or directory, 5432 error?

I’m trying to run psql on my Vagrant machine, but I get this error: psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”? Note: Vagrant 1.9.2 Box: ubuntu/trusty64, EDIT Commands I’ve used in order to install and run postgres: … Read more

PostgreSQL: role is not permitted to log in

I have trouble connecting to my own postgres db on a local server. I googled some similar problems and came up with this manual so: pg_hba.conf says: # TYPE DATABASE USER ADDRESS METHOD # “local” is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all … Read more

Truncating all tables in a Postgres database

I regularly need to delete all the data from my PostgreSQL database before a rebuild. How would I do this directly in SQL? At the moment I’ve managed to come up with a SQL statement that returns all the commands I need to execute: SELECT ‘TRUNCATE TABLE ‘ || tablename || ‘;’ FROM pg_tables WHERE … Read more

Is it better to use multiple databases with one schema each, or one database with multiple schemas?

After this comment to one of my questions, I’m thinking if it is better using one database with X schemas or vice versa. I’m developing a web application where, when people register, I create (actually) a database (no, it’s not a social network: everyone must have access to his own data and never see the … Read more