Trying to configure postgres on OSX

I am trying to install postgres locally for a rails application on my mac (10.7 Lion).

I installed postgresapp and launched it, now I have an elephant in the status bar telling me that postgres is running.

I can get to him:

psql -h localhost 

But when I just run psql , I get this error:

psql: could not connect to the server: permission denied Server is running locally and accepts connections in the Unix socket domain "/var/pgsql_socket/.s.PGSQL.5432"?

I put this:

 PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" 

In ~/.bashrc and opened a new terminal. But not cubes.

When I run which psql , I get /usr/bin/psql

Not sure what to do. I'm still pretty new to unix systems. Should I link /usr/bin/psql to /Applications/Postgres.app/Contents/MacOS/bin/psql ?

+6
source share
2 answers

I had a similar issue on my new MacBook Pro running on Mountain Lion. I downloaded PostgresApp , and when I turned on the rails, I got the following error:

 `initialize': could not connect to server: No such file or directory (PG::Error) Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? 

To fix this, I had to explicitly define the host and port in my database.yml file as follows:

 development: adapter: postgresql encoding: unicode database: my_app_development pool: 5 username: tony password: stark host: localhost port: 5432 
+11
source

This error is quite specific and tells you what is wrong, but if you are new to unix, then this is less obvious.

I gave a similar answer here:

Unable to connect to local PostgreSQL

Problem

You do not have access to the file ("socket") /var/pgsql_socket/.s.PGSQL.5432

To fix it:

Make sure you have access to the directory. At the command line use:

 ls -l /var/pgsql_socket/.s.PGSQL.5432 

This will result in a “permission denial” if not. You probably already have access to this, and it's just a socket file that you do not have rights to.

The socket file itself is created by postgresql at startup.

Track the main configuration file for postgres ( postgresql.conf ). This in itself can be difficult; I'm a Linux user, not OSX. You may need to spend some time on Google. This link is quite old, but may lead you to the right path if you encounter problems. http://www.postgresqlformac.com/server/howto_edit_postgresql_confi.html

Once you find it, find the lines in postgresql.conf, they should say something like:

 unix_socket_directory = '/var/pgsql_socket' # dont worry if yours is different #unix_socket_group = '' # default is fine here unix_socket_permissions = 0777 # check this one 
+4
source

Source: https://habr.com/ru/post/923005/


All Articles