Using PostgreSQL With Laravel


By default Laravel ships with MySQL. You may want to try out other SQL database type, changing that is very simple however there are some small configurations you have to make if your database of choice is postgres.

1. Installation

Download PostgreSQL to your pc from

Or directly here (for windows)

Then Install.

2. php.ini

MySQL is the default therefore there’s need to activate PostgreSQL for use with PHP on your pc by editing the php.ini

Search for these two lines within your php.ini and remove the “;” in front of each:


to (notice that “;” was removed)


3. .env

Change the following as appropriate within the Laravel’s .env file (all the defaults are ok except DB_DATABASE and DB_PASSWORD that you may have to change):


4. Migration

Create your migration files as usual and run migration.

ORM (Object-relational mapping) handles the underlining differences between different SQL databases (sqlite, MySQL, postgres), there is no need for any extra work as your migration command run successfully.

Hope this helps.




Backend Developer | SEO

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tony Ayeni

Tony Ayeni

Backend Developer | SEO

More from Medium

Nginx install on windows

Deploying Laravel to Heroku via Git (CD)

How To Install Old Version Laravel Using Composer

Use NGINX hosting static websites