Skip to content

Instantly share code, notes, and snippets.

@jrod01
Created June 3, 2012 14:21
Show Gist options
  • Save jrod01/2863707 to your computer and use it in GitHub Desktop.
Save jrod01/2863707 to your computer and use it in GitHub Desktop.
postgresql trouble
# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
# gem install pg
# On Mac OS X with macports:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#
development:
adapter: postgresql
encoding: unicode
database: q_man_development
pool: 5
username: q_man
password:
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
#host: localhost
#port: 5432
# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public
# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
# log, notice, warning, error, fatal, and panic
# The server defaults to notice.
#min_messages: warning
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: postgresql
encoding: unicode
database: q_man_test
pool: 5
username: q_man
password:
production:
adapter: postgresql
encoding: unicode
database: q_man_production
pool: 5
username: q_man
password:
@jrod01
Copy link
Author

jrod01 commented Jun 3, 2012

tarted GET "/assets/rails.png" for 127.0.0.1 at 2012-06-02 19:25:25 -0400

PG::Error (could not connect to server: Connection refused
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
):
activerecord (3.2.3) lib/active_record/connection_adapters/postgresql_adapter.rb:1194:in initialize' activerecord (3.2.3) lib/active_record/connection_adapters/postgresql_adapter.rb:1194:innew'
activerecord (3.2.3) lib/active_record/connection_adapters/postgresql_adapter.rb:1194:in connect' activerecord (3.2.3) lib/active_record/connection_adapters/postgresql_adapter.rb:329:ininitialize'
activerecord (3.2.3) lib/active_record/connection_adapters/postgresql_adapter.rb:28:in new' activerecord (3.2.3) lib/active_record/connection_adapters/postgresql_adapter.rb:28:inpostgresql_connection'
activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:303:in new_connection' activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:313:incheckout_new_connection'
activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:237:in block (2 levels) in checkout' activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:232:inloop'
activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:232:in block in checkout' /Users/jonathanrodriguez/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:inmon_synchronize'
activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in checkout' activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:95:inconnection'
activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in retrieve_connection' activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_specification.rb:168:inretrieve_connection'
activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in connection' activerecord (3.2.3) lib/active_record/query_cache.rb:67:inrescue in call'
activerecord (3.2.3) lib/active_record/query_cache.rb:61:in call' activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:467:incall'
actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in block in call' activesupport (3.2.3) lib/active_support/callbacks.rb:405:in_run__585171263221763089__call__3788526546944628307__callbacks'
activesupport (3.2.3) lib/active_support/callbacks.rb:405:in __run_callback' activesupport (3.2.3) lib/active_support/callbacks.rb:385:in_run_call_callbacks'
activesupport (3.2.3) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb:27:incall'
actionpack (3.2.3) lib/action_dispatch/middleware/reloader.rb:65:in call' actionpack (3.2.3) lib/action_dispatch/middleware/remote_ip.rb:31:incall'
actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:16:in call' actionpack (3.2.3) lib/action_dispatch/middleware/show_exceptions.rb:56:incall'
railties (3.2.3) lib/rails/rack/logger.rb:26:in call_app' railties (3.2.3) lib/rails/rack/logger.rb:16:incall'
actionpack (3.2.3) lib/action_dispatch/middleware/request_id.rb:22:in call' rack (1.4.1) lib/rack/methodoverride.rb:21:incall'
rack (1.4.1) lib/rack/runtime.rb:17:in call' activesupport (3.2.3) lib/active_support/cache/strategy/local_cache.rb:72:incall'
rack (1.4.1) lib/rack/lock.rb:15:in call' actionpack (3.2.3) lib/action_dispatch/middleware/static.rb:62:incall'
railties (3.2.3) lib/rails/engine.rb:479:in call' railties (3.2.3) lib/rails/application.rb:220:incall'
rack (1.4.1) lib/rack/content_length.rb:14:in call' railties (3.2.3) lib/rails/rack/log_tailer.rb:14:incall'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in service' /Users/jonathanrodriguez/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:inservice'
/Users/jonathanrodriguez/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in run' /Users/jonathanrodriguez/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:inblock in start_thread'

@jrod01
Copy link
Author

jrod01 commented Jun 3, 2012

jrod:~ jonathanrodriguez$ brew update
Updated Homebrew from 557387b7 to 6837be69.
==> New Formula
akka avidemux checkstyle dwatch iozone jboss-forge jpeginfo logcheck pdf2image scm-manager storm treecc
arangodb camellia crash htop-osx ispc jless libvo-aacenc mpich2 readosm ser2net tn5250 xrootd
==> Updated Formula
abcde cmake freexl hbase libmagic mupdf pianobar
abyss cminpack fsh hdf5 libmicrohttpd musepack pipebench
ack coda-cli ftjam highlight libmikmod mydumper pixie
aften collada-dom fuse4x hilite libmp3splt mysql pkg-config
android-ndk colordiff fuse4x-kext hllib libmpc mysql-connector-c play
android-sdk convmv fwknop htpdate libmusicbrainz mysql-connector-c++ pngrewrite
apiextractor coreutils gauche httping libogg mysqlreport podofo
apollo couchdb gcal httrack liboping mytop points2grid
app-engine-java-sdk couchdb-lucene gccxml hub libpar2 nacl polipo
appledoc cpansearch gdal ice libplist nagios poppler
appswitch cracklib-words gearman ifuse libqglviewer nagios-plugins postgis
apt-dater crossroads geda-gaf imagemagick librasterlite nasm povray
aria2 csup gegl imapfilter libraw ncview primesieve
armadillo ctags generatorrunner innotop libreplaygain ndiff proj
arp-scan cvs2svn getxbook intltool libspatialite neko psftools
arss daemon gflags io libssh net-snmp pure
asciidoc daq ghc iodine libssh2 net6 putty
asciitex dart ghostscript ioping libtasn1 netcdf pygobject
assimp darwinbuild giflib ios-sim libtiff newick-utils pygtk
atk dash git ispell libtool newlisp pypy
atlassian-plugin-sdk dc3dd git-cola ivy libutf nginx pyqt
atool dcal git-flow jack libvirt ngircd pyqwt
audiofile dcmtk git-ftp jbig2dec libvorbis nmap pyside
augeas ddd git-multipush jbigkit libvpx node pyside-tools
autoconf ddrescue git-now jcal libwbxml noweb python
autojump devil git-sh jenkins libyubikey nrpe python3
automake dia git-url-sub jetty link-grammar nss qemu
automoc4 diffpdf gitslave jigdo little-cms num-utils qhull
avanor direnv glib john llvm nzbget qjson
avro-c dmenu gmap-gsnap jp2a log4cxx o-make qpdf
bash dnscrypt-proxy gmp jruby logtalk objective-caml qt
bash-completion dnsmasq gmtl json_spirit loudmouth ocrad quassel
bazaar dos2unix gnu-arch jstalk luarocks octave rabbitmq
bbcp doxygen gnupg jsvc magit ode rakudo-star
bdw-gc drizzle gnuplot justniffer mairix open-cobol rasqal
beanstalk drush go jython malbolge open-scene-graph rbenv
bibutils duplicity go-app-engine-32 knife-completion mapnik opencc rc
bindfs dvtm go-app-engine-64 kyoto-cabinet mathomatic opencolorio reattach-to-user-namespace
bonnie++ dwm gobby kyoto-tycoon maxima opencv recode
boost eet gobject-introspection kytea mcpp openimageio redis
boost-build eigen google-app-engine lame md5sha1sum openmeeg repo
box2d eina google-js-test lasi media-info openssl roundup
bulk_extractor ejabberd gpg-agent lastfm_fplib mercurial opentracker rrdtool
byobu elasticsearch gpsbabel lastfmfpclient metasploit osm2pgsql rsense
c-ares embryo gptfdisk latex2rtf metis otx rtorrent
calabash erlang gradle lcov mg p7zip rubinius
camlp5 exiftool grads ldid mhash pango ruby
cassandra exim grails ledger midgard2 par2tbb ruby-build
catdoc exodriver graphviz ledit minc parallel saga-core
ccrypt ezlupdate grass lftp mkvtoolnix parmetis sbcl
cd-discid fann griffon libagg mlton pcb sbt
cdo fastjar groonga libcouchbase mobile-shell pdal sc68
cdparanoia fastri growly libcuefile mongodb pdf2json scala
cfengine ffmbc gsoap libdbusmenu-qt mongrel2 pdf2svg scantailor
cfitsio ffmpeg gst-ffmpeg libdnet monit pdfgrep sedna
cherokee ffmpeg2theora gst-plugins-bad libechonest monotone pdflib-lite shark
chromaprint fftw gst-plugins-base libelf moreutils peg shiboken
chuck figlet gst-plugins-good libevent mosh perceptualdiff sigar
clam fish gst-plugins-ugly libewf mosquitto percona-server signing-party
clay flann gstreamer libgaiagraphics movgrab percona-toolkit simgrid
clhep fluid-synth gtk-doc libgit2 mp3splt perforce simh
clisp fmdiff gtkwave libglade mpfr perforce-proxy sipp
cliweather fortune gwenhywfar libidn mpg123 perforce-server snort
cloc fping gwyddion libimobiledevice mpop pgbouncer solr
clojure freeimage hadoop liblas msmtp pgpool-ii sonar
clucene freerdp haxe liblqr mu physfs sound-touch
spatialindex swig tiff2png ttytter vcftools weechat xclip
spatialite-tools symphony tig tup vcodex wget xmp
sphinx tabbed tkdiff two-lame vimpc wiggle xspringies
spidermonkey taglib tmap uchardet vmalloc wine yaml-cpp
spring-roo tal tmux unifdef vrpn wkhtmltopdf yarp
sqlite task todo-txt unrar vtk wput ykclient
ssh-copy-id tbb tomcat urweb wait_on wv2 ykpers
sshfs tcpurify topgit usbmuxd wbox wxmac zeromq
stunnel teem tor uudeview wdfs x264 zint
subversion tesseract trafficserver vala wdiff xapian zsh
swftools the_silver_searcher transcode valgrind web100clt xchat
==> Deleted Formula
agrep avocadodb go-gui openttd riak-search
jrod:~ jonathanrodriguez$ brew install postgresql
==> Installing postgresql dependency: readline
==> Downloading http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz

################################################################## 100.0%

==> Downloading patches

################################################################## 100.0%
################################################################## 100.0%

==> Patching
patching file vi_mode.c
patching file callback.c
patching file support/shobj-conf
patching file patchlevel
==> ./configure --prefix=/usr/local/Cellar/readline/6.2.2 --mandir=/usr/local/Cellar/readline/6.2.2/share/man --infodir=/usr/local/Cellar/readline/6.2.2/share/info --enable-multibyte
==> make install
==> Caveats
This formula is keg-only, so it was not symlinked into /usr/local.

OS X provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.

Generally there are no consequences of this for you.
If you build your own software and it requires this formula, you'll need
to add its lib & include paths to your build variables:

LDFLAGS  -L/usr/local/Cellar/readline/6.2.2/lib
CPPFLAGS -I/usr/local/Cellar/readline/6.2.2/include

==> Summary
/usr/local/Cellar/readline/6.2.2: 30 files, 1.5M, built in 31 seconds
==> Installing postgresql dependency: ossp-uuid
==> Downloading ftp://ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz

################################################################## 100.0%
################################################################## 100.0%==> ./configure --disable-debug --without-perl --without-php --without-pgsql --prefix=/usr/local/Cellar/ossp-uuid/1.6.2

==> make
==> make install
/usr/local/Cellar/ossp-uuid/1.6.2: 12 files, 312K, built in 17 seconds
==> Installing postgresql
==> Downloading http://ftp.postgresql.org/pub/source/v9.1.3/postgresql-9.1.3.tar.bz2

################################################################## 100.0%

==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.3 --datadir=/usr/local/Cellar/postgresql/9.1.3/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.1.3/share/doc/postgresql --
==> make install-world
==> Caveats

Build Notes

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/mxcl/homebrew/issues/issue/2510

To build plpython against a specific Python, set PYTHON prior to brewing:
PYTHON=/usr/local/bin/python brew install postgresql
See:
http://www.postgresql.org/docs/9.1/static/install-procedure.html

Create/Upgrade a Database

If this is your first install, create a database with:
initdb /usr/local/var/postgres

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

Start/Stop PostgreSQL

If this is your first install, automatically load on login with:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.1.3/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

If this is an upgrade and you already have the homebrew.mxcl.postgresql.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
cp /usr/local/Cellar/postgresql/9.1.3/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Or start manually with:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

And stop with:
pg_ctl -D /usr/local/var/postgres stop -s -m fast

Loading Extensions

By default, Homebrew builds all available Contrib extensions. To see a list of all
available extensions, from the psql command line, run:
SELECT * FROM pg_available_extensions;

To load any of the extension names, navigate to the desired database and run:
CREATE EXTENSION [extension name];

For instance, to load the tablefunc extension in the current database, run:
CREATE EXTENSION tablefunc;

For more information on the CREATE EXTENSION command, see:
http://www.postgresql.org/docs/9.1/static/sql-createextension.html
For more information on extensions, see:
http://www.postgresql.org/docs/9.1/static/contrib.html

Other

Some machines may require provisioning of shared memory:
http://www.postgresql.org/docs/current/static/kernel-resources.html#SYSVIPC

To install postgresql (and ossp-uuid) in 32-bit mode:
brew install postgresql --32-bit

If you want to install the postgres gem, including ARCHFLAGS is recommended:
env ARCHFLAGS="-arch x86_64" gem install pg

To install gems without sudo, see the Homebrew wiki.
==> Summary
/usr/local/Cellar/postgresql/9.1.3: 2746 files, 36M, built in 4.2 minutes
jrod:~ jonathanrodriguez$ psql -d postgres < /usr/local/Cellar/postgresql/9.0.1/share/contrib/adminpack.sql
-bash: /usr/local/Cellar/postgresql/9.0.1/share/contrib/adminpack.sql: No such file or directory
jrod:~ jonathanrodriguez$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment