Here is how to create a user and grant remote login with the Mac OS X Postgres.app without adding a system account.
Postgres.app is a nice, packaged version of Postgresql that just runs out of the box on Mac OS X. Most tutorials for Postgres assume you are using system users to authenticate anything connecting to the database server, but on Mac OS X this may not make as much sense.
Here are the steps to allow remote connections and create a user:
CREATE DATABASE test_db;
CREATE USER test_user WITH PASSWORD 'test_password_here_134325235235';
Find the comment that mentions listen_addresses and add the last line below:
#listen_addresses = 'localhost' # what IP address(es) to listen on; # comma-separated list of addresses; # defaults to 'localhost'; use '*' for all # (change requires restart) listen_addresses = '*'
This will allow connections from anywhere, but no one can actually connect until you perform the next step.
Add this line to the end of the file, modifying the user and database:
host test_db test_user 0.0.0.0/0 md5
This allows test_user to connect to the database test_db from any IP address, using the md5 authentication scheme. In general do not set other values for the last option as these are insecure (unless you take other steps).
psql --host=HOST_IP_ADDRESS --username=test_user test_db
Comments (0)