PostgreSQL is available on QNAP App Center |
Version 9.2.1 is newer (My Ubuntu installed version 9.3). |
OptIPKG's postgresql ipkg is older |
After install PostgreSQL, just click Launch to connect and login with the administrator account "postgres".
QNAP also includes pgAdmin (with PHP Web UI) into the package. |
1. Change password of "postgres" from Control Panel of QTS.
What is the password of "postgress"? |
Control Panel / Privilege / Users: postgres account was added due to install PostgreSQL |
Successfully connected! |
2. Change settings of PostgreSQL through SSH.
Edit the configuration file: postgresDB/postgresql.conf
Remove the remark# from this config line ( #listen_addresses = 'localhost' ) so that this QNAP web server (localhost) can connect to PostgreSQL. Or change ( #listen_addresses = 'localhost' ) to ( listen_addresses = '*' ), if you want public hosts to be able to connect with this postgresql server. (But it's danger!)
Edit the configuration file: postgresDB/postgresql.conf
Remove the remark# from this config line ( #listen_addresses = 'localhost' ) so that this QNAP web server (localhost) can connect to PostgreSQL. Or change ( #listen_addresses = 'localhost' ) to ( listen_addresses = '*' ), if you want public hosts to be able to connect with this postgresql server. (But it's danger!)
NOTE: I've changed my RAID0 SATA HDs into one SSD HD to make QNAP quite.
Find pg_hba.conf file in the PostgreSQL installation directory.
Edit the pg_hba.conf (Host-Based Authencation) to allow public hosts to be able to connect with this server. Check following examples to set your pgsql client-server environment.
[/share/HDA_DATA/.qpkg/PostgreSQL/postgresDB] # nano pg_hba.conf
...
# IPv4 local connections:host all all 127.0.0.1/32 trust # only allow localhost to connect
host all all localhost trust # only allow localhost to connect
host all all 0.0.0.0/0 md5 # allow all public host to connect
host all all 192.168.0.0/24 md5 # allow IPs 192.168.0.* to connect...
Notably, when you login Linux (Ubuntu or QNAP) with admin (the root), its not the root of PostgreSQL, but "psql -U postgres" command can login PostgreSQL without typing password. Check the pg_hba.conf, the following line means that PostgreSQL trust
# "local" is for Unix domain socket connections onlyHowever, PostgreSQL connections from other hosts or local web services (i.e. running PHP programs in the same machine with PostgreSQL) should be verified with dbuser accounts rather than Unix accounts and "postgres". Running PHP web services with "postgres" is dangerous, each service should be isolated with different dbusers for different databases.
local all all trust
Consequently, I suggest that you should set all Authentication method as md5 (encoded vs. password, not encoded) . If you set trust, some phpPgAdmin implementation may treat the setting as "trust connection" so that anonymous can login through "right" account name with "any" password string. In my QNAP, I set as follows to let postgresql accounts be accessible from localhost and hosts in the same network segments.
host all all localhost md5 # only allow localhost to connect
host all all 192.168.0.0/24 md5 # allow IPs 192.168.0.* to connect
No comments :
Post a Comment