Setup - Mac M1
1
1. Install PostgreSQL using Homebrew
Install Homebrew (if you don't have it installed):
Open the terminal and run:
Copy
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install PostgreSQL:
Run the following command in the terminal:
Copy
brew install postgresql
Start PostgreSQL Service:
Start the PostgreSQL service:
Copy
brew services start postgresql
Verify Installation:
Check the version to ensure it is installed correctly:
Copy
psql --version
2. Initialize the Database
Initialize the database:
Copy
Start the PostgreSQL Server:
Copy
3. Create a User and Database
Access PostgreSQL Shell:
Copy
Create a New User:
Copy
Create a New Database:
Copy
Grant Privileges:
Copy
Exit the Shell:
Copy
4. Configure PostgreSQL
Edit
postgresql.conf(optional for specific configurations):Locate the file:
Copy
Adjust settings like
listen_addressesto allow remote connections if needed.
Restart the Service:
Copy
5. Connect to PostgreSQL
From the Command Line:
Copy
Using a GUI Tool:
You can use tools like pgAdmin, Postico, or DBeaver for a graphical interface to manage your PostgreSQL databases.
6. (Optional) Install pgAdmin
Download and install pgAdmin for a GUI-based interaction with PostgreSQL.
2
PgAdmin setup
1. Install pgAdmin using Homebrew
Open your terminal.
Run the following command to install pgAdmin:
Copy
2. Launch pgAdmin
After installation, you can find pgAdmin in your Applications folder.
Open it directly by navigating to Applications > pgAdmin 4.
Alternatively, run it from the terminal:
Copy
3. Initial Setup
When you open pgAdmin for the first time, it will ask for a Master Password to secure your configurations:
Create a password and remember it.
After setting the master password, you'll see the pgAdmin interface.
4. Connect pgAdmin to PostgreSQL
In the pgAdmin interface, click on "Add New Server" (top-left corner).
Fill in the details:
General Tab:
Name: Enter a name for your server (e.g.,
Local PostgreSQL).
Connection Tab:
Host name/address:
localhostPort:
5432(default PostgreSQL port)Maintenance Database:
postgresUsername: Your PostgreSQL username (default is
postgres).Password: Your PostgreSQL password.
Click Save.
5. Verify the Connection
If everything is configured correctly, you should see your PostgreSQL server in the left panel of the pgAdmin interface.
You can expand it to see databases, schemas, tables, etc.
6. Troubleshooting (if needed)
Ensure PostgreSQL is Running:
Verify that the PostgreSQL service is running:
Copy
If it's not running, start it:
Copy
Check the Host and Port:
Make sure the
postgresql.conffile allows connections:Copy
Set
listen_addressesto:Copy
Restart PostgreSQL:
Copy
Last updated