Also, for advanced users, you can use PostgreSQL 9.1+. After switching to the user postgres (sudo su - postgres), you may use the following commands:
- createuser --pwprompt --encrypted --no-adduser --no-createdb <username>
- createdb --encoding=UNICODE --owner=<username> <database>
- Then in the file of pg_hba.conf file (/etc/postgresql/<version>/main/pg_hba.conf), add the following line at the bottom to give the user access from any remote connection:
host <database> +<username> 0.0.0.0/0 md5 - In the file of postgresql.conf, change the following line with localhost to either * or your server address alias:
listen_addresses = 'localhost,<www.alias.com>' # what IP address(es) to listen on;- # comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
- # comma-separated list of addresses;
- sudo systemctl restart postgresql