My laptop has a small hard drive. I want to load a big data set. I have moved the entire
/usr/local/var/postgres to the external hd, and symlinked it back. Now I'm getting this error,
psql: could not connect to server: Socket operation on non-socket
Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
I have now found the problem. Changing the default data directory causes Postgres to refuse connections to the server. The online Manual is a little [sic!] unspecific about "config files in the same directory"…
The solution I used (with psql) is to:
CREATE TABLESPACE tablespacename OWNER username LOCATION '/Path/to/Folder'
CREATE DATABASE databasename OWNER username TABLESPACE tablespacename
psql databasename < /Path/to/databasedump.sql
NOTE to future visitors of this question; please see the warning below from Craig Ringer regarding how to solve this problem properly.