# Creating postgresql user account by hand



## Ethin (Nov 28, 2018)

I had no idea where to put this, so I put it here. I apologize if this goes in a more specific category; I couldn't find an appropriate one, so just posted it here (since it does concern a port, but one I built myself). Anyway, I built Postgresql 11.1 from their source code downloads, but have no idea how to create the user account for it to run under. I tried digging through the port to see if that would reveal something I'm missing but no luck there either. So, how do I create the user account that pkg creates without actually installing the package?


----------



## VladiBG (Nov 28, 2018)

Build it from ports. You can find it in /usr/ports/databases/postgresql11-server

It will create the user postgres and group postgres UID 770 for you.


----------



## ShelLuser (Nov 28, 2018)

Look into adduser(8) or pw(8) (pw is better if you need the process to be automated).

Still, why not rely on databases/postgresql11-server or the binary package instead? No need to build the sourcecode yourself: `# pkg install postgresql11-server` and done.


----------



## obsigna (Nov 28, 2018)

ShelLuser said:


> ...
> Still, why not rely on databases/postgresql11-server or the binary package instead? No need to build the sourcecode yourself: `# pkg install postgresql11-server` and done.



Perhaps, because conservative people do like the classic uid 70 for user pgsql so much more compared to the fancy new one 770 for user postgres.

The first thing which I do after installing PostgreSQL > 9 from the ports is:
`pw userdel postgres; pw useradd -u 70 -n pgsql -c "PostgreSQL Daemon" -d /usr/local/pgsql -s /bin/sh`


----------



## Ethin (Nov 29, 2018)

I built it manually because it wasn't showing up in pkg as a package, and I have the latest pkg repository information. Ill check again but either way, there's no point in building it from ports since I already built it from source. Thank you for the command though -- I'll definitely be using that. Thanks all for your suggestions.


----------

