YouTip LogoYouTip

Mac Install Postgresql

# How to Install and Set Up PostgreSQL on macOS PostgreSQL is a powerful, open-source object-relational database system known for its reliability, feature robustness, and performance. This comprehensive guide walks you through installing PostgreSQL on macOS using the EnterpriseDB graphical installer, configuring your database, and managing it using both the command-line interface (`psql`) and the graphical management tool (pgAdmin 4). --- ## 1. Introduction to EnterpriseDB For macOS users, **EnterpriseDB (EDB)** provides the official, highly recommended graphical installer for PostgreSQL. EDB is a leading global provider of enterprise-class products and services built integration-ready on PostgreSQL. The installer bundles the PostgreSQL database server, pgAdmin (a graphical administration tool), and Stack Builder (for installing additional drivers and extensions). --- ## 2. Downloading and Installing PostgreSQL ### Step 1: Download the Installer Go to the official EnterpriseDB download page: [https://www.enterprisedb.com/downloads/postgres-postgresql-downloads](https://www.enterprisedb.com/downloads/postgres-postgresql-downloads) Select the appropriate PostgreSQL version for macOS and download the `.dmg` installer file. ### Step 2: Run the Installer 1. Locate the downloaded `postgresql-****-osx.dmg` file in your Downloads folder and double-click to mount it. 2. Double-click the installer package inside to launch the setup wizard. 3. When prompted, enter your macOS administrator password to grant the installer permission to proceed. ### Step 3: Complete the Setup Wizard The setup wizard will guide you through the installation process. For most development environments, you can accept the default settings by clicking **Next** on each screen. The wizard will prompt you for: * **Installation Directory:** The location where PostgreSQL files will be stored. * **Data Directory:** The directory where your databases and tables will reside. * **Password:** Set a secure password for the default database superuser (`postgres`). **Make sure to remember this password.** * **Port:** The default port is `5432`. * **Locale:** Default locale or your specific regional setting. Once configured, click **Next** to begin the installation, and click **Finish** when the process is complete. --- ## 3. Verifying the Installation via Command Line After a successful installation, you can connect to your PostgreSQL server using the command-line tool `psql`. Run the following script in your Terminal to launch the interactive shell: ```bash $ /Library/PostgreSQL/11/scripts/runpsql.sh ;exit ``` *(Note: Replace `11` in the path above with your installed PostgreSQL major version number if you installed a newer version).* During execution, the terminal will prompt you for connection parameters. You can press **Enter** to accept the default values (shown in brackets) or type your custom values: ```text Server : Database : Port : Username : Password for user postgres: psql (11.3) Type "help" for help. postgres=# ``` Once you see the `postgres=#` prompt, you are successfully connected to the PostgreSQL server as the superuser. --- ## 4. Managing PostgreSQL with pgAdmin 4 **pgAdmin 4** is the leading graphical administration and management tool for PostgreSQL. It is automatically installed alongside the database server. ### Step 1: Launch pgAdmin 4 You can open pgAdmin 4 in one of two ways: * Open your macOS **Applications** folder and double-click **pgAdmin 4**. * Click the PostgreSQL "elephant" icon in the macOS menu bar at the top right of your screen and select pgAdmin. ### Step 2: Connect to the Server 1. Once the pgAdmin web interface loads, locate the browser tree on the left-hand side. 2. Expand the **Servers** node. 3. Click on your PostgreSQL server instance (e.g., **PostgreSQL 11** or **PostgreSQL 12**). 4. A dialog box will appear prompting you for the password. Enter the superuser password you configured during the installation process and click **OK**. ### Step 3: Explore the Dashboard Once authenticated, you will be directed to the main dashboard. Here, you can monitor real-time server activity, manage databases, write SQL queries using the built-in Query Tool, and configure database schemas, tables, and users. --- ## 5. Key Considerations & Troubleshooting * **Environment Variables:** To run `psql` directly from any Terminal window without typing the full path, add PostgreSQL's `bin` directory to your system path. Add the following line to your `~/.zshrc` or `~/.bash_profile` file: ```bash export PATH="/Library/PostgreSQL//bin:$PATH" ``` * **Port Conflicts:** If the installer warns you that port `5432` is already in use, it means another instance of PostgreSQL (perhaps installed via Homebrew) is running. You can either stop the existing service or assign a different port (e.g., `5433`) during installation. * **Firewall Permissions:** If you plan to connect to this database from other machines on your local network, ensure that your macOS Firewall allows incoming connections on port `5432` and configure the `pg_hba.conf` file accordingly.
← Vuejs Ajax AxiosLinux Install Postgresql β†’