How to install PostgreSQL on Mac

Shemika Donalene - Jul 26 - - Dev Community

Image description
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)"
Enter fullscreen mode Exit fullscreen mode

2.Update the local database of Homebrew:

brew update
Enter fullscreen mode Exit fullscreen mode

3.Install PostgreSQL using Homebrew:

brew install postgresql
Enter fullscreen mode Exit fullscreen mode

4.Start PostgreSQL service:

brew services start postgresql
Enter fullscreen mode Exit fullscreen mode

5.Create a new PostgreSQL user and database:

createuser --superuser myuser
createdb mydatabase
Enter fullscreen mode Exit fullscreen mode

6.Login to PostgreSQL:

psql -U myuser -d mydatabase
Enter fullscreen mode Exit fullscreen mode

Image description

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

. . . .