亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在Mac OS X上啟動PostgreSQL服務器?

如何在Mac OS X上啟動PostgreSQL服務器?

慕的地8271018 2020-02-03 13:48:34
最后更新:我忘記了運行initdb命令。</最終更新>通過運行此命令ps auxwww | grep postgres我看到postgres沒有運行> ps auxwww | grep postgresremcat          1789   0.0  0.0  2434892    480 s000  R+   11:28PM   0:00.00 grep postgres這提出了一個問題:如何啟動postgresql服務器?更新:>pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log startserver startingsh: /usr/local/var/postgres/server.log: No such file or directory更新2:觸摸不成功,所以我改為這樣做:> mkdir /usr/local/var/postgres> vi /usr/local/var/postgres/server.log> ls /usr/local/var/postgres/          server.log但是,當我嘗試啟動Rails服務器時,仍然看到以下內容:Is the server running on host "localhost" and acceptingTCP/IP connections on port 5432?更新3:> pg_ctl -D /usr/local/var/postgres statuspg_ctl: no server running更新4:我發現那里沒有pg_hba.conf(只有pg_hba.conf.sample),所以我修改了示例并將其重命名(以刪除.sample)。這里是內容: # IPv4 local connections: host    all             all             127.0.0.1/32           trust # IPv6 local connections: host    all             all             ::1/128                trust但我不明白這一點:> pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start     server starting> pg_ctl -D /usr/local/var/postgres status                                     pg_ctl: no server running也:sudo find / -name postgresql.conffind: /dev/fd/3: Not a directoryfind: /dev/fd/4: Not a directory更新5:sudo pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log startPassword:pg_ctl: cannot be run as rootPlease log in (using, e.g., "su") as the (unprivileged) user that will own the server process.更新6:這似乎很奇怪:> egrep 'listen|port' /usr/local/var/postgres/postgresql.confegrep: /usr/local/var/postgres/postgresql.conf: No such file or directory不過,我確實這樣做:>sudo find / -name "*postgresql.conf*"find: /dev/fd/3: Not a directoryfind: /dev/fd/4: Not a directory/usr/local/Cellar/postgresql/9.0.4/share/postgresql/postgresql.conf.sample/usr/share/postgresql/postgresql.conf.sampl
查看完整描述

3 回答

?
一只名叫tom的貓

TA貢獻1906條經驗 獲得超3個贊

該自制包管理器包括launchctl的Plist自動啟動。有關更多信息,請運行brew info postgres。


手動啟動:


pg_ctl -D /usr/local/var/postgres start


手動停止:


pg_ctl -D /usr/local/var/postgres stop


自動啟動:


“要啟動現在啟動postgresql并在登錄時重新啟動:”


brew services start postgresql


是什么結果pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start?


是什么結果pg_ctl -D /usr/local/var/postgres status?


server.log中是否有任何錯誤消息?


確保在pg_hba.conf中啟用了tcp localhost連接:


# IPv4 local connections:

host    all             all             127.0.0.1/32            trust

檢查postgresql.conf中的listen_addresses和端口:


egrep 'listen|port' /usr/local/var/postgres/postgresql.conf


#listen_addresses = 'localhost'     # what IP address(es) to listen on;

#port = 5432                # (change requires restart)

打掃干凈


Postgres很可能是通過Homebrew,Fink,MacPorts或EnterpriseDB安裝程序安裝的。


檢查以下命令的輸出,以確定安裝了哪個軟件包管理器:


brew && brew list|grep postgres

fink && fink list|grep postgres

port && port installed|grep postgres


查看完整回答
反對 回復 2020-02-03
?
慕容708150

TA貢獻1831條經驗 獲得超4個贊

如果要手動啟動和停止postgresql(通過homebrew安裝),最簡單的方法是:


brew services start postgresql


brew services stop postgresql


查看完整回答
反對 回復 2020-02-03
  • 3 回答
  • 0 關注
  • 1341 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號