Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to PostgreSQL database with Laravel Homestead?

I have updated the DB connection in my .env file to change the default mysql database to use PostgreSQL DB. But I don't know how to proceed with this.

DB_CONNECTION=pgsql

For example, we use

mysql -uhomestead -psecret <DB Name>

to connect to our database. By using psql, how to connect to DB?

like image 821
suguna Avatar asked Mar 17 '16 06:03

suguna


People also ask

How connect PostgreSQL to laravel?

Laravel makes connecting with Postgres databases and running queries extremely simple out of the box. The Postgres database configuration for your application is located at Laravel Project Root Folder, config/database. php . In this file you may define Postgres database connection for your Laravel Application.

How do I connect to Homestead database?

Connecting To Your Databases To connect to your MySQL or Postgres database from your main machine via Navicat or Sequel Pro, you should connect to 127.0. 0.1 and port 33060 (MySQL) or 54320 (Postgres). The username and password for both databases is homestead / secret .


1 Answers

Try this one,

psql -U homestead -h localhost <DB Name>

After that, it will ask for password, enter secret. That's it.

like image 157
Anandhan Avatar answered Oct 13 '22 01:10

Anandhan