step by step设置postgresql用户密码并配置远程连接
生活随笔
收集整理的這篇文章主要介紹了
step by step设置postgresql用户密码并配置远程连接
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
設(shè)置pgsql默認(rèn)用戶posgres的密碼
1、確認(rèn)pgsql是開啟的?/etc/init.d/postgresql status 2、使用默認(rèn)用戶登錄 sudo su postgres 3、進(jìn)入psql客戶端 命令為 sudo -u postgres psql 進(jìn)入之后就可以寫sql了 4、執(zhí)行第三步如果出現(xiàn)“postgres is not in the sudoers file. ?This incident will be reported.”提示則需要在sudoers里面加上postgres,步驟如下: 1) 輸入命令 su - 進(jìn)入超級用戶模式(如果當(dāng)前不是root用戶,則進(jìn)行root身份驗(yàn)證); 2)?chmod u+w /etc/sudoers 為sudoers文件添加寫的權(quán)限(默認(rèn)是只讀) 3)?vim /etc/sudoers 編輯sudoers文件,在root ALL=(ALL) ALL這一行下面加上 postgres??ALL=(ALL) ALL 4)撤銷sudoers文件可寫?chmod u-w /etc/sudoers 5、繼續(xù)執(zhí)行第三步,進(jìn)入psql客戶端之后執(zhí)行?postgres=# ALTER USER postgres with password '123456';(將默認(rèn)的postgres用戶密碼設(shè)置為123456,注意語句后面一定要加分號),postgres=# \q 退出psql客戶端設(shè)置pgsql遠(yuǎn)程連接
1、修改pgsql配置文件postgresql.conf(默認(rèn)位于安裝目錄的data子文件夾下)。找到?listen_addresses = 'localhost' 這一行,將localhost修改為 * 所有ip都允許連接,并取消注釋 2、port = 5432 取消注釋 3、修改pg_hda.conf(和postgresql.conf同一個目錄),在末尾加一行??host ? ?all ? ? ? ? all ? ? ? ? 0.0.0.0/0 ? ? ?md5 4、開啟5432端口: iptables -I INPUT -p tcp --dport 5432 -j ACCEPT /etc/init.d/iptables save /etc/init.d/iptables restart轉(zhuǎn)載于:https://www.cnblogs.com/error500/p/3305956.html
總結(jié)
以上是生活随笔為你收集整理的step by step设置postgresql用户密码并配置远程连接的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux查找文件或字符串的命令
- 下一篇: 【转】ArcGIS API for Si