I'm having a hard time getting postgres going for the first time. I installed pg with homebrew and I'm getting a error that looks pretty common on here:
createuser: could not connect to database postgres: could not connect
to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
I've read that the most common solution is to remove the postmaster.pid file by running rm /usr/local/var/postgres/postmaster.pid
However, this results in the following:
rm: /usr/local/var/postgres/postmaster.pid: Permission denied
Any idea how I can get this going?
Related
I need to save a database to an external HDD. This question has been asked previously here. However, upon changing the data_directory variable in the postgresql.conf file that exists in /usr/local/var/postgres/ to
data_directory = /path/to/externalHDD/directory/
I then restart the PostgreSQL server with brew services restart postgresql, but when I try to reconnect to the database via
psql -U username -d postgres
I receive the following error:
psql: error: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
How do I fix this?
If all you did was point data_directory somewhere else, that cannot work, because there is no data directory at the destination. You have to create the data directory using initdb.
I'm following this tutorial on how to run Postgres on MAC OS X with MAMP. But I can't seem to add PostgreSQL to my PATH variable. When I run export PATH="/Library/PostgreSQL/11/bin" I get this error:
prompt_context:13: command not found: whoami
prompt_background_jobs:1: command not found: wc
prompt_background_jobs:2: command not found: awk
Here's exactly what I did:
I downloaded PostgreSQL 11.2 from Enterprise DB
I installed it using the installer:
username: postgres
password: postgres
port: 5433
The PostgreSQL folder can now be found here: /Library/PostgreSQL. Inside there's a folder called 11. Inside /Library/PostgreSQL/11 I can see the bin folder and data folder.
There's another folder inside my Applications folder called PostgreSQL 11. Here I can see a Documentation folder and some other programs I believe:
Application Stack Builder
pgAdmin 4
Reload Configuration
SQL Shell (psql)
The following error appears when I ignore setting the PATH variable and run su postgres:
su: Sorry
or sudo postgres:
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise. See the documentation for
more information on how to properly start the server
Also, running psql gives me this error, because PostgreSQL is not included in my environmental variables:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Note: this error asks if the server is accepting Unix domain socket with a port 5432, while I installed PostgreSQL on port 5433, what's up with that? Moving to /Library/PostgreSQL/11/bin with cd and running sudo ./psql (should run the Unix Executable file psql) gives me the same error.
Resources that didn't help me any further:
Createuser: could not connect to database postgres: FATAL: role "tom" does not exist
https://dba.stackexchange.com/questions/3005/how-to-run-psql-on-mac-os-x
Psql could not connect to server: No such file or directory, 5432 error?
When you run export PATH="/Library/PostgreSQL/11/bin" you are telling the system that all the commands you need are in that single directory. Since you also need standard system utilities like wc you also need to include the directories where they reside in your PATH. Normally you would do this to simply add the postgres directories to the list of directories searched for commands:
export PATH="/Library/PostgreSQL/11/bin:$PATH"
I don't know how this happened, but my postgres server (9.6.2) has stopped working locally. I seem to be able to start it up, and stop it using:
brew services start postgresql and brew services start postgresql but when I try to connect using psql 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 "/tmp/.s.PGSQL.5432"?
When I try to see if anything is listening on port 5432 using lsof -i :5432 I get nothing.
Looked at other posts that say check the pg_hba.conf file, which I did, but doesn't seem to be the problem.
I ended up reinstalling postgres via homebrew. That by itself didn't do enough. I had to kill my data directory to get this to work (i.e. rm -rf /path/to/my/data/directory) and then rebuild it using initdb.
This solution obviously only works if you don't care about keeping your data (in my case, it was just data for my dev environment, so I didn't). If you do want to save a copy of your data, I you'd have to come up with something else.
We have the small array of Greenplum database.In that, We have a master node. when I am trying to use PSQL utility
Getting this error :
[gpadmin#master gpseg-1]$ psql
PSQL: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
We tried
on searching for postmaster.pid files.We have removed it.But still, the error remains.
You need to export your PGPORT and source Postgres.sh_path(inside your GPDB).
After that you will be able to do psql and connect to the database.
I'm going crazy with postgresql (9.1) installation on my server (debian) i have rent on gandi.net !
I did the aptitude get-install postgresql postgresql-client command.
I'm having this error when trying to execute psql command.
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"?
I've been searching on the web. And maybe the servers are not running. I don't know how to check and how to launch them.
My postgres command doesn't work either (command not found).
Any idea?
The database engine is not running.
service postgresql start
or
/etc/init.d/postgresql start
to start the engine. I don't remember though if debian initializes the data dir automatically.