I am using MAMP on my MAC. As it comes with MySQL by default. But now I need to use PostgreSQL in one of my project. How can I setup postgreSQL in MAMP for Laravel project?
Ok if you are set on using postgreSQL over mySQL that comes with MAMP you have to manually install postgreSQL on you location machine the OSX packages can be found here,
If you don't want to do a full install i recommend this Postgres App just download an extract to your applications folder then when you launch it the port number will be displayed in the menu bar like so:
create a database:
CREATE DATABASE your_database_name;
CREATE DATABASE
Tip to exit postgreSQL CLI use \q
then ENTER
You now need to plug these settings into Laravels configuration:
'default' => 'mysql',
with 'default' => 'pgsql',
now with the information from before edit the 'connections'
array like so:
'connections' => array( 'pgsql' => array( 'driver' => 'pgsql', 'host' => 'localhost', 'database' => 'your_database_name', 'username' => '', 'password' => '', 'charset' => 'utf8', 'prefix' => '', 'schema' => 'public', ), )
save file
You should now have a functioning database that Laravel can talk to.
Note you do not need the username or password in database config if you are using the Postgres App.