5

I'm using Mac OS X 10.8.5 and trying to install postgreSQL using homebrew. I've fixed several errors and warnings which have occurred when I ran brew info postgresql. However, I don't know how to fix the rest of the problems.

$brew info postgresql

postgresql: stable 9.3.2 (bottled)
http://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.3.2 (2924 files, 40M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/commits/master/Library/Formula/postgresql.rb
==> Dependencies
Required: readline ✔
Recommended: ossp-uuid ✔
==> Options
--32-bit
    Build 32-bit only
--enable-dtrace
    Build with DTrace support
--no-perl
    Build without Perl support
--no-tcl
    Build without Tcl support
--without-ossp-uuid
    Build without ossp-uuid support
--without-python
    Build without python support
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
  https://github.com/Homebrew/homebrew/issues/issue/2510

To migrate existing data from a previous major version (pre-9.3) of PostgreSQL, see:
  http://www.postgresql.org/docs/9.3/static/upgrading.html

When installing the postgres gem, including ARCHFLAGS is recommended:
  ARCHFLAGS="-arch x86_64" gem install pg

To install gems without sudo, see the Homebrew wiki.

To have launchd start postgresql at login:
    ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
    postgres -D /usr/local/var/postgres

When I run server, I get:

/usr/local/rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `initialize': could not connect to server: No such file or directory (PG::ConnectionBad)
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

I've uninstalled postgresql and reinstalled but seems like I wasn't able to remove the postgresql 8.x version.

I've read several different posts to install and run postgreSQL properly and tried what they've suggested but nothing seems to be working for me.

1
  • 1
    Ugh, the packaging situation for PostgreSQL on Mac OS X is awful. In this case, please find the PostgreSQL log files for your homebrew install of PostgreSQL and examine them to see why it appears not to be starting. Also check the process list (ps -ef | grep postgres) to see if it's actually running after all. Commented Jan 16, 2014 at 23:31

2 Answers 2

3

Installing PostgreSQL in Mac OS X El Capitan using homebrew

First check the 'owner' of the folder '/usr/local' by using this command:

$ ls -la '/usr'

If the owner of the file is 'root', run this command to change the owner to your currently logged user:

$ sudo chown -R `whoami` /usr/local

Install PostgreSQL using homebrew:

$ brew update
$ brew doctor
$ brew install postgresql@15

and that's it!

Uninstall PostgreSQL using homebrew:

$ brew uninstall postgres

then remove this folder: '/usr/local/var/postgres' and then change back the owner of your local local folder to:

$ sudo chown -R root /usr/local

How to:

List brew services: $ brew services list

Run brew services: $ brew services start <service_name>

ex: $ brew services start postgresql

Stop brew serices: $ brew services stop <service_name>

Logging in to PostgreSQL for the first time:

1.) Run the postgres: $ brew services start postgresql (postgresql@15 in this case)

2.) Create a db using your username: $ createdb `whoami`

3.) Login to postgres: $ psql To quit psql, just type: \q

4.) Create database (using terminal):

$ createdb <db_name>

psql tutorial:

http://blog.trackets.com/2013/08/19/postgresql-basics-by-example.html http://exponential.io/blog/2015/02/21/install-postgresql-on-mac-os-x-via-brew/

Optional, installing pgAdmin:

1.) Download pdadmin: https://www.pgadmin.org/download/macosx.php

2.) Press ctrl+click then open to run the dmg file then drag it to your Application folder. ctrl+click the pdadmin to run it so that it won't ask for that annoying question again.

Login in to pgAdmin:

Note: Use your username and password when you installed your postgres for first login then create a new user with privileges later or just change your password from 'File -> Change Password...'

Sign up to request clarification or add additional context in comments.

Comments

0

Your Ruby code is apparently linked against the system version of PostgreSQL, which looks for a socket in /var/pgsql_socket. The Homebrew version would look in /tmp. (At this point, make sure that a file like /tmp/.s.PGSQL.5432 exists.) To work around this, you can tell your code to connect to the Homebrew version by specifying /tmp with the "host" option, however your code spells that.

In the future, make sure your Ruby gems are linked against the Homebrew version. Perhaps just uninstalling and reinstalling with the right paths set would do it.

3 Comments

I'm not following what I need to do here. I hope I had more knowledge in these area. so, I would greatly appreciate if you could elaborate or enumerate. Sorry for the hassle.
Unclear what you what should be done here. What does it mean if the file isn't there? Or what if it is there? This answer isn't an answer.
The question also wasn't a question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.