PostgreSQL installation takes 10 to 15 minutes and works the same way on Windows, Mac, and Linux
PostgreSQL is a database system that stores and organizes data for applications and websites. You download an installer from the official PostgreSQL website, run it, choose where to save the files, set a password for the main account, and finish. The installer handles most of the setup automatically. After installation, PostgreSQL runs in the background and is ready to use.
The steps differ slightly depending on your operating system, but the overall process is identical: get the right installer, run it, answer a few questions, and you are done. This guide walks through each system separately so you can follow the exact steps for yours.
Key Takeaways
- Download the PostgreSQL installer from postgresql.org, not from a third-party site, to avoid outdated or modified versions.
- During installation, you will be asked to set a password for the "postgres" account — write this down because you will need it later to connect to the database.
- On Windows and Mac, the installer creates a folder and adds PostgreSQL to your system automatically; on Linux, you use your package manager instead.
- After installation finishes, PostgreSQL runs as a background service and starts automatically when you restart your computer.
- You can verify the installation worked by opening a terminal or command prompt and typing a single command to check the version number.
Installing PostgreSQL on Windows
Go to postgresql.org/download/windows in your web browser. Click the link that says "Download the installer" — it will be labeled with the latest version number. The file will be named something like "postgresql-16-x64-setup.exe" (the number changes as new versions release). Save it to your Downloads folder.
Double-click the installer file. Windows may ask if you want to allow this program to make changes to your computer — click "Yes". The PostgreSQL Setup Wizard will open. Click "Next" on the welcome screen. On the next screen, you can change where PostgreSQL installs — the default location (usually C:\Program Files\PostgreSQL) works fine for most people. Click "Next" again.
The installer will ask which components to install. Leave all boxes checked unless you have a specific reason not to. Click "Next". You will then see a screen asking where to store data files — again, the default location is fine. Click "Next". The installer will ask you to set a password for the "postgres" account. This is the main administrative account for your database. Type a password you will remember, type it again to confirm, and click "Next".
The next screen asks about the port number — leave it as 5432 unless you know you need to change it. Click "Next". The installer will ask about locale settings — the default is usually correct. Click "Next" one more time, then click "Install". The installer will run for a few minutes. When it finishes, uncheck the box that says "Launch Stack Builder" and click "Finish". PostgreSQL is now installed.
Installing PostgreSQL on Mac
Go to postgresql.org/download/macosx in your web browser. You will see two main options: the graphical installer or Homebrew. The graphical installer is simpler if you have never used Homebrew. Click "Download the installer" and save the file to your Downloads folder.
Double-click the installer. A window will open showing the PostgreSQL installer. Double-click the icon that looks like a folder with an arrow — this is the actual installer application. Your Mac may ask if you want to open an application from the internet — click "Open". The PostgreSQL Setup Wizard will appear. Click "Next" on the welcome screen.
On the next screen, choose where to install PostgreSQL — the default location works fine. Click "Next". You will see a list of components to install — leave all boxes checked. Click "Next". The installer will ask where to store data files — the default is fine. Click "Next". You will be asked to set a password for the "postgres" account. Type a password you will remember and type it again to confirm. Click "Next".
The next screen shows the port number — leave it as 5432. Click "Next". Check the locale settings and click "Next" again. Click "Install". The installer will run for a few minutes. When it finishes, uncheck "Launch Stack Builder" and click "Finish". PostgreSQL is now installed and will start automatically.
Installing PostgreSQL on Linux
Linux installation uses your system's package manager instead of a graphical installer. The exact commands depend on which Linux distribution you use. Open a terminal window.
On Ubuntu or Debian: Type this command and press Enter: sudo apt update. Wait for it to finish. Then type: sudo apt install postgresql postgresql-contrib and press Enter. The system will ask if you want to continue — type "y" and press Enter. The installation will run automatically. When it finishes, PostgreSQL is ready to use.
On Fedora, CentOS, or RHEL: Type this command and press Enter: sudo dnf install postgresql-server postgresql-contrib. The system will ask if you want to continue — type "y" and press Enter. After installation finishes, type: sudo systemctl start postgresql and press Enter. Then type: sudo systemctl enable postgresql to make PostgreSQL start automatically when you restart.
On Arch Linux: Type: sudo pacman -S postgresql and press Enter. When prompted, type "y" and press Enter. After installation, type: sudo systemctl start postgresql and then: sudo systemctl enable postgresql.
Verify the installation worked
After installation finishes on any system, you can check that PostgreSQL is working. Open a terminal (Mac or Linux) or Command Prompt (Windows). Type this command and press Enter: psql --version. The system will print the PostgreSQL version number — something like "psql (PostgreSQL) 16.0". If you see a version number, the installation was successful.
If the command does not work on Windows, you may need to add PostgreSQL to your system path. Go to Start, search for "Environment Variables", and click "Edit the system environment variables". Click "Environment Variables" at the bottom. Under "System variables", find the one called "Path", click it, and click "Edit". Click "New" and type: C:\Program Files\PostgreSQL\16\bin (replace "16" with your version number if different). Click "OK" three times. Close Command Prompt and open a new one, then try the version command again.
Connect to your database for the first time
After you verify the version, you can connect to PostgreSQL to make sure it is fully working. Type this command and press Enter: psql -U postgres. The system will ask for the password you set during installation. Type it and press Enter. You will see a prompt that looks like: postgres=#. This means you are connected to the database. Type \q and press Enter to disconnect.
If you cannot remember the password you set, you will need to reset it. On Windows, open pgAdmin (a tool that installed with PostgreSQL) from your Start menu. On Mac or Linux, open a terminal and type: sudo -u postgres psql. Then type: ALTER USER postgres WITH PASSWORD 'newpassword'; (replace "newpassword" with what you want). Press Enter and type: \q to exit.
What to do if installation fails
If the installer will not run on Windows, make sure you downloaded it from postgresql.org and not from another website. Antivirus software sometimes blocks installers — temporarily disable it and try again. If you get an error about missing files, restart your computer and try the installer again.
On Mac, if you get a message saying the installer cannot be opened, right-click it and select "Open With" and choose "Installer". On Linux, if the package manager says PostgreSQL is already installed but you cannot connect, type: sudo systemctl restart postgresql to restart the service.
If you installed PostgreSQL but cannot connect to it, the service may not be running. On Windows, open Services (search for it in the Start menu), find "postgresql-x64-16" or similar, and make sure it says "Running". On Mac or Linux, type: sudo systemctl status postgresql to check if it is running.
Frequently Asked Questions
Do I need to restart my computer after installing PostgreSQL?
No, you do not need to restart. PostgreSQL starts automatically after installation finishes. However, restarting does not hurt and can sometimes fix connection problems if you run into them.
Can I install PostgreSQL without administrator rights?
On Windows and Mac, the installer requires administrator access. On Linux, you need sudo access to use the package manager. If you do not have these permissions, ask your system administrator to install it for you.
What is the "postgres" password used for?
The "postgres" account is the main administrative account for your database system. You use this password when you first connect to PostgreSQL to create other accounts and databases. Keep it somewhere safe.
Can I install multiple versions of PostgreSQL on the same computer?
Yes, but they must use different port numbers. During installation, change the port from 5432 to something else like 5433. This lets both versions run at the same time without interfering with each other.
How much disk space does PostgreSQL need?
The PostgreSQL program itself takes about 100 to 200 megabytes. Your databases will take additional space depending on how much data you store in them. Most computers have plenty of room.