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

5 postgresql ubuntu homebrew linuxbrew

我在我的Ubuntu上安装Postgresql:

brew install postgres

我现在有:

psql --version
psql (PostgreSQL) 9.5.0
Run Code Online (Sandbox Code Playgroud)

如何自动启动服务?

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

ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Run Code Online (Sandbox Code Playgroud)

但是如何在Ubuntu上使用Linuxbrew?

我试着用:

brew services start postgresql

但它说:

sh: 1: list: not found
Error: Could not read the plist for `postgresql`!
Run Code Online (Sandbox Code Playgroud)

该怎么办?

rho*_*dee 10

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

$ pg_ctl start -D $HOME/.linuxbrew/var/postgres -l logfile
Run Code Online (Sandbox Code Playgroud)

你可以在你的.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"
Run Code Online (Sandbox Code Playgroud)

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

$ poston
$ createdb `whoami`
$ psql
Run Code Online (Sandbox Code Playgroud)