Check out example codes for "how-can-i-start-postgresql-server-on-mac-os-x". It will help you in understanding the concepts better.

Code Example 1

If you want to manually start and stop PostgreSQL (installed via Homebrew), the easiest way is:

brew services start postgresql

and

brew services stop postgresql

If you have a specific version, make sure to suffix the version. For example:

brew services start [email protected]

Learn ReactJs, React Native from akashmittal.com