There are several ways to install PostgreSQL on macOS, one of which is to use the Homebrew package manager. The following are the steps to install PostgreSQL through Homebrew:
1.If you have not installed Homebrew yet, please run the following command in the terminal to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2.Update the local database of Homebrew:
brew update
3.Install PostgreSQL using Homebrew:
brew install postgresql
4.Start PostgreSQL service:
brew services start postgresql
5.Create a new PostgreSQL user and database:
createuser --superuser myuser
createdb mydatabase
6.Login to PostgreSQL:
psql -U myuser -d mydatabase
Congratulations, you have successfully installed PostgreSQL on your Mac!
If you are too fond of tedious operations and command-line installation, then I recommend another way, servbay, which is a graphical way to install PostgreSQL and is also very convenient for one click deployment.
Thank you for reading my article