我尝试了以下操作但失败了
bash-3.2$ pg_ctl restart
pg_ctl: no database directory specified and environment variable PGDATA unset
Run Code Online (Sandbox Code Playgroud)
我正在使用Macbook Pro
并且不记得我的数据存储的目录,因此也无法设置PGDATA,有没有办法重新启动Postgres而不会丢失数据?
谢谢
a_h*_*ame 21
正如你想重新启动 Postgres我假设服务器已经在运行.
使用超级用户帐户,您可以通过SQL查询数据目录的位置:
select name, setting
from pg_settings
where name = 'data_directory'
Run Code Online (Sandbox Code Playgroud)
使用该信息,您可以使用-D
开关将数据目录提供给pg_ctl命令(有关详细信息,请参阅手册)
pja*_*mer 17
如果您使用过,brew
您可以通过执行以下操作找到重启(启动|停止)指令brew info postgresql
.由于某些原因,在操作系统启动时我看到plist未加载,因此发生了一些问题.我总是忘记该做什么,这有帮助.
在我的Postgres 9.2酿造食谱上它有:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Run Code Online (Sandbox Code Playgroud)
Jer*_*one 11
一个班轮(默认postgresSql 9.6安装)
sudo su postgres -c "/Library/PostgreSQL/9.6/bin/pg_ctl restart -D /Library/PostgreSQL/9.6/data"
Run Code Online (Sandbox Code Playgroud)
完整版本
获取pgdata文件夹(给我/Library/PostgreSQL/9.6/data)(感谢@a_horse_with_no_name)
select name, setting from pg_settings where name = 'data_directory';
Run Code Online (Sandbox Code Playgroud)
对我来说它返回'/Library/PostgreSQL/9.6/data'
然后
sudo su - postgres
./bin/pg_ctl restart -D /Library/PostgreSQL/9.6/data
Run Code Online (Sandbox Code Playgroud)
注意:postgres的用户主目录应为"/Library/PostgreSQL/9.6"
归档时间: |
|
查看次数: |
19250 次 |
最近记录: |