Setting up a Postgres on a Mac with EnterpriseDB
When I was doing this I found Shawn Hartsock’s blog post useful.
In essence this is what you do to set
I used the EnterpriseDB Postgres download.
In order to make the correlation between Shawn Hartsock’s post and Enterprise DB on a Mac, Sachin Srivastava gave me the following tips:
a) /var/lib/pgsql/data corresponds to the PGDATA directory which in turn for default installations by EnterpriseDB goes to (/Library/PostgreSQL/8.4/data) for version 8.4
b) sudo /etc/init.d/postgresql restart corresponds to restarting the postgresql service whose equivalent for EnterpriseDB in mac is following 2 commands:
sudo launchctl stop com.edb.launchd.postgresql-8.4
sudo launchctl start com.edb.launchd.postgresql-8.4
When EnterpriseDB installs Postgres, by default it will run on port 8080. This conflicted with Tomcat.
I found this blog post useful and created an alias
alias ports='lsof -i -P | grep -i "listen"'
I found I had to make the following tweaks:
- phpgAdmin: /Library/PostgreSQL/EnterpriseDB-ApachePhp/apache/conf/httpd.conf
(after looking in /Library/PostgreSQL/EnterpriseDB-ApachePhp/installer/ApachePhp/startupcfg.sh, then /Library/LaunchDaemons/com.edb.launchd.apache.plist)
I changed port 8080 to 8081 in two places
* Listen 8081
* ServerName localhost:8081
- Open file /etc/postgres-reg.ini and change the value of APACHE_PORT in the ApachePhp Section, i.e.
You obviously have to make sure the DB Server is running prior to creating Postgres users or databases. The start/stop/restart options are shown in the Applications folder.
In essence this is what you do to setup a new database:
- cd // Changes to home dir
- sudo su // Sign on as super user – will prompt for password
- su postgres // Assume the identity of postgres from super user
- createuser -P <grails db user> //Provided the server is started, you will then be prompted for a password for the new role followed by three y/n answers, each of which you reply ‘n’ to (superuser, create databases and create new roles questions. Finally you will be prompted for the Postgres DB password (There is a corresponding dropuser command. I didn’t see a Postgres list users command)
- createdb <grails db> // You will be prompted for Postgres DB password again. (There is a corresponding dropdb command for which you must give your Postgres DB password too)
- psql <grails db> // Supply Postgres DB password
- psql \l // Shows a list of databases in pg_database – you may have to hit Enter a few times to scroll through listing until prompt returns
- ALTER DATABASE <grails db name> OWNER TO <grails db user>;
- You use \q to get out of the Postgres shell and back to Unix land. (You’ll probably get an access denied message at this point. Some sort of logging quirk with Enterprise DB config & OS/X security. It’s nothing to worry about)
- The exit to get back out of the postgres user account
- Followed by a final exit to get back out of the auspicies of the super user.
Peter Ledbrook also mentioned you can use the following command:
sudo psql -host localhost –username <grails db user> –password