12

我在我的 Ubuntu 上安装 Postgresql:

brew install 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

但是在带有 Linuxbrew 的 Ubuntu 上怎么样?

我尝试:

brew services start postgresql

但它说:

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

该怎么办?

4

1 回答 1

17

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

$ 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
于 2016-02-28T07:43:30.577 回答