Linuxbrew, install postgres and start the service automatically

I install Postgresql on my Ubuntu using:

brew install postgres

Now I have:

psql --version
psql (PostgreSQL) 9.5.0

How to start the service automatically?

On my homegrown Mac, I can do this with:

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

but how on ubuntu with linuxbrew?

I'm trying to:

brew services start postgresql

but he says:

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

What to do?

+4
source share
2 answers

Not entirely automatic, but a step in the right direction. On my system, I did the following:

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

You can simply create an alias in .bash_profileor .bashrc, for example:

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

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

To test all this (if you do not already have a database on your computer), you can also create a database for your current user:

$ poston
$ createdb `whoami`
$ psql
+9

Source: https://habr.com/ru/post/1627337/


All Articles