加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-13 16:05:10 所属栏目:百科 来源:网络整理
导读:我在我的Ubuntu上安装 Postgresql: brew安装postgres 我现在有: psql --versionpsql (PostgreSQL) 9.5.0 如何自动启动服务? 在我的Mac上用自制软件我可以用: ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgentslaunchctl load ~/Library
我在我的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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读