Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres permission denied on MAC OS X

Tags:

I was following the ruby on rails tutorial to run with postgres but when I try the "rake db:create" I get the following error:

could not connect to server: Permission denied     Is the server running locally and accepting     connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? 

I have found this question issuing some similar problem but I couldnt make it work anyway.

Repairing Postgresql after upgrading to OSX 10.7 Lion

I have installed homebrew after reading this question and the path is fine, brew doctor shows me no errors on path.

like image 358
Andre Cytryn Avatar asked May 29 '12 00:05

Andre Cytryn


People also ask

How do I fix postgres permission denied?

Grant privileges to a new user We resolve this permission denied error using the command. GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO new_user; The new_user was then able to read data from the table. Similarly, we can also resolve the permission denied error by setting DEFAULT privileges to the user.

How do I connect to PostgreSQL database on Mac?

The default username for postgres is postgres. (If you are using Advanced Server it is enterprisedb.) On a Mac or Windows, you are able to connect to the default instance by simply hitting enter at the shell or command prompt when trying to run psql and keying in the password.

How do I check PostgreSQL status on Mac?

It is better to use another method like using psql to run a simple query and checking the exit code, e.g. psql -c 'SELECT 1' , or use pg_isready to check the connection status. psql -c "SELECT 1" -d {dbname} > /dev/null || postgres -D /usr/local/var/postgres >postgres.


2 Answers

Instead of troubleshooting your socket file permissions, you could try a TCP connection. Add host: localhost to your config/database.yml. Of course, this will only work if postgres is listening for TCP traffic. Postgres listens on port 5432 by default, so netstat -an | grep 5432 will tell you if it is listening.

References

  • PostgreSQL Documentation: 18.3. Connections and Authentication.
like image 128
Jared Beck Avatar answered Oct 19 '22 13:10

Jared Beck


Oh, may be you are open postgre in another application, like pgadmin http://www.pgadmin.org/ Try to close any application that use postgre SQL and run your command again.

like image 39
duykhoa Avatar answered Oct 19 '22 13:10

duykhoa