title: How to install PostgreSQL 9.1 on OSX Lion
body: <p>I downloaded PostgreSQL from the official website and ran the .dmg installer. After that I downloaded pgadmin3 and I am indeed able to connect to the database. </p>
  
  <p>when I run 'psql' I get the following error:</p>
  
  <pre><code>psql: could not connect to server: No such file or directory
      Is the server running locally and accepting
  </code></pre>
  
  <p>After hours of googling I read about some $PATH issues, so I put this into my .bashrc:</p>
  
  <pre><code>export PATH=/Library/PostgreSQL/9.1/bin:$PATH
  </code></pre>
  
  <p>However, this doesn't solve the error above at all. After some more hours of googling I tried to run 'psql -l localhost -U postgres'. This gives another error:</p>
  
  <pre><code>psql: could not connect to server: Connection refused
      Is the server running on host "localhost" (::1) and accepting
      TCP/IP connections on port 5432?
  could not connect to server: Connection refused
      Is the server running on host "localhost" (127.0.0.1) and accepting
      TCP/IP connections on port 5432?
  could not connect to server: Connection refused
      Is the server running on host "localhost" (fe80::1) and accepting
      TCP/IP connections on port 5432?
  </code></pre>
  
  <p>After some more googling I tried to edit /Library/PostgreSQL/9.1/data/pg_hba.conf and replaced all occurrences of 'md5' with 'trust'. </p>
  
  <p>Then I changed user to postgres and executed 'pg_ctl stop' and 'pg_ctl start', switched back to my own user and tried to connect again, no luck.</p>
  
  <p>Here are some more infos:</p>
  
  <pre><code>[~]$ which psql
  /Library/PostgreSQL/9.1/bin/psql
  
  ps aux | grep postgres
  postgres       19022   0.0  0.0  2446096    484   ??  Ss   11:31PM   0:00.01 postgres: stats collector process   
  postgres       19021   0.0  0.0  2486532   1776   ??  Ss   11:31PM   0:00.01 postgres: autovacuum launcher process   
  postgres       19020   0.0  0.0  2486400    576   ??  Ss   11:31PM   0:00.03 postgres: wal writer process   
  postgres       19019   0.0  0.0  2486400    820   ??  Ss   11:31PM   0:00.05 postgres: writer process   
  postgres       19017   0.0  0.0  2446096    356   ??  Ss   11:31PM   0:00.01 postgres: logger process   
  postgres       19015   0.0  0.1  2486400   8216 s001  S    11:31PM   0:00.17 /Library/PostgreSQL/9.1/bin/postgres
  
  sudo find / -name .s.PGSQL.5432
  No file was found?!?
  </code></pre>
  
  <p>Update 1:
  In /etc/sysctl.conf I added the values suggested by the installer's README:</p>
  
  <pre><code>kern.sysv.shmmax=1610612736
  kern.sysv.shmall=393216
  kern.sysv.shmmin=1
  kern.sysv.shmmni=32
  kern.sysv.shmseg=8
  kern.maxprocperuid=512
  </code></pre>
  
  <p>Before these settings, the installer quits with an error, afterwards the wizard appears and installs postgres (and again, using pgadmin3 works, so I assume that the database is running fine).</p>