1. 初始化
$ sudo postgresql-setup initdb
2. 啟用並開始
$ sudo systemctl enable postgresql
$ sudo systemctl start postgresql
3. 修改密碼
sudo -u postgres psql postgres
# \password postgres
Enter new password:
4. 修改認證方式
$ sudo vi /var/lib/pgsql/data/pg_hba.conf 搜尋以下段落修改IP及驗證方式改為trust
# “local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 0.0.0.0/0 trust
# IPv6 local connections:
host all all ::1/128 trust
5. 驗證密碼
psql -U postgres -W
6. 打開監聽讓遠端存取
看config檔位置:
(在psql中)SHOW config_file; (預設在: /var/lib/pgsql/data/postgresql.conf)
$ sudo vi /var/lib/pgsql/data/postgresql.conf 修改成 listen_addresses = ‘*’
===
PS: phpPgAdmin 須改的設定
vi /var/www/html/phpPgAdmin/config.inc.php 修改成 $conf[‘extra_login_security’] = false