Connect PostgreSQL Database in Laravel with pgAdmin + Hosting

Budi Odank
2 min readMar 22, 2023

--

Logo PostgreSQL from wikipedia

PostgreSQL also known as Postgres, is a free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance.

Now we will connected PostgreSQL with Laravel 9 via pgAdmin 4 and Hosting Database

  1. Download pgAdmin

Link Download : https://www.pgadmin.org/download/

2. Upload database on your hosting

Database from hosting

3. Configuration database in pgAdmin

3.1 Click Add New Server

pgAdmin 4

3.2 On Tab General, fill Name with your domain

Setting server in pgAdmin

3.3 On Tab Connection, fill in as follows

Host name/address     : 127.0.0.1
Port : 5432
Maintenace database : yourdbname
Username : yourusernamedb
Password : yourpassworddb

3.4 On Tab SSH Tunnel, fill in as follows

Use SSH tunneling    : active
Tunnel Host : yourdomain.com
Tunnel Port : 64000 or SSH Port
Username : username cpanel
Password : password cpanel

3.5 Click Save

And you see your database in pgAdmin

4. Configuration Laravel on File .env

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=49262 or you can check on pgAdmin Properties (see picture B)
DB_DATABASE=yourdbname
DB_USERNAME=yourusernamedb
DB_PASSWORD=yourpassworddb
Configuration file .env (A)
Configuration server database in pgAdmin (B)

5. Run Laravel

--

--

Budi Odank
Budi Odank

Written by Budi Odank

Mahasiswa Penunggu Wisuda di Masa Pandemi

No responses yet