微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

postgresql – Linuxbrew,安装postgres并自动启动服务

我在我的Ubuntu上安装 Postgresql

brew安装postgres

我现在有:

psql --version
psql (Postgresql) 9.5.0

如何自动启动服务?

在我的Mac上用自制软件我可以用:

ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

但是如何在Ubuntu上使用linuxbrew

我试着用:

brew服务启动postgresql

但它说:

sh: 1: list: not found
Error: Could not read the plist for `postgresql`!

该怎么办?

解决方法

不是很自动,而是朝着正确的方向迈出了一步.在我的系统上,我做了以下事情:

$pg_ctl start -D $HOME/.linuxbrew/var/postgres -l logfile

您可以在.bash_profile或.bashrc中简单地创建一个别名:

alias poston="pg_ctl start -D $HOME/.linuxbrew/var/postgres -l logfile"

alias postoff="pg_ctl stop -D $HOME/.linuxbrew/var/postgres"

要全部测试(假设您的计算机上还没有数据库),您还可以为当前用户创建一个数据库

$poston
$createdb `whoami`
$psql

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐