First written: April 27, 2014 at 7:55pm
OSX since Lion comes with postgres but it seems a little hard to figure out exactly how to get it running so I thought
I'd read a short entry so I could remember how I did it.
(1) Check if postgres is running:
sudo serveradmin fullstatus postgres
(2) If it is not running you can get it running with the command:
sudo serveradmin start postgres
(3) Make sure postgres is listening to localhost:
cd /Library/Server/PostgreSQL/Config/
sudo nano org.postgresql.postgres.plist
change
listen_addresses=
to
listen_addresses=127.0.0.1
save and then type:
sudo serveradmin stop postgres
sudo serveradmin start postgres
(4) Use template1 to create database accounts
sudo -u _postgres psql template1
CREATE USER myusername WITH PASSWORD 'mypassword';
CREATE DATABASE mydatabase;
GRANT ALL PRIVILEGES ON mydatabase TO myusername;
\q
(5) You should now be able to connect to the database from
a terminal window using:
psql -d mydatabase -u myusername
(6) Another thing you may need to do is
cd /Library/Server/PostgreSQL/Data
you might want to change the default trust settings for connections
specified in pg_hba.conf to some other kind of authentication.
For example,
host all myusername 127.0.0.1/32 password
'''First written: April 27, 2014 at 7:55pm'''
OSX since Lion comes with postgres but it seems a little hard to figure out exactly how to get it running so I thought
I'd read a short entry so I could remember how I did it.
(1) Check if postgres is running:
sudo serveradmin fullstatus postgres
(2) If it is not running you can get it running with the command:
sudo serveradmin start postgres
(3) Make sure postgres is listening to localhost:
cd /Library/Server/PostgreSQL/Config/
sudo nano org.postgresql.postgres.plist
change
listen_addresses=
to
listen_addresses=127.0.0.1
save and then type:
sudo serveradmin stop postgres
sudo serveradmin start postgres
(4) Use template1 to create database accounts
sudo -u _postgres psql template1
CREATE USER myusername WITH PASSWORD 'mypassword';
CREATE DATABASE mydatabase;
GRANT ALL PRIVILEGES ON mydatabase TO myusername;
\q
(5) You should now be able to connect to the database from
a terminal window using:
psql -d mydatabase -u myusername
(6) Another thing you may need to do is
cd /Library/Server/PostgreSQL/Data
you might want to change the default trust settings for connections
specified in pg_hba.conf to some other kind of authentication.
For example,
host all myusername 127.0.0.1/32 password