2

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?

1

1 Answer 1

12

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:

Postgres.app

create a database:

  1. go to menu above Click on Open psql
  2. In the command line create you database like so: CREATE DATABASE your_database_name;
  3. should return CREATE DATABASE

Tip to exit postgreSQL CLI use \q then ENTER

You now need to plug these settings into Laravels configuration:

  1. open file: %laravel_directory%/app/config/database.php
  2. in the array replace 'default' => 'mysql', with 'default' => 'pgsql',
  3. 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',
        ),
    )
  4. 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.

Sign up to request clarification or add additional context in comments.

2 Comments

Could elaborate this You should not have a functioning database that Laravel can talk to? What do you mean by this sentence?
LIkely meant to type "now" instead of "not". Common typo - I can't edit because I need at least 6 character difference to edit other people's responses :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.