Solved Postgresql (95) - pg_ctl vs postgresql

I am learning how to install and use PostgreSQL server and I have run across a few different tutorials. One of them had me running postgresql commands from /usr/local/etc/rc.d. However, I initially didn't see the directory and the command wasn't working so I ended up finding pg_ctl and doing the following:
pg_ctl initdb -D data
pg_ctl -D data -l logs/pgsql-data.log start

When I realized that I probably just don't have /usr/local/etc/rc.d in PATH, I stopped the server using pg_ctl stop -D data, rm -r data/. (All of these commands thus far were done under pgsql user.) I then went into root and did:
/usr/local/etc/rc.d/postgresql initdb
/usr/local/etc/rc.d/postgresql start

These two coommands seemed to do the same thing (building /usr/local/pgsql/data database) except the log is in a different place.

So, my question is: which of these methods makes the most sense? Does the /usr/local/etc/rc.d/postgresql method do more "magic" in the background that I should rely on? I was also worried about the server starting after a reboot; does this work for any databases I've started?

Thank you,

-gns
 
I had it in my head that it was a separate binary for some reason, but that explains everything.
Files in /usr/local/etc/rc.d/ are never binaries, they're always scripts. Never used PostgreSQL but for MySQL, MariaDB and a few others the start scripts will "automagically" run their initialization if it's the first time you started it. It's safe to assume it works the same way for PostgreSQL.
 
Back
Top