0

I am trying to get a laravel5-example project working. One of the steps seems very basic but I do not know how to do it:

Create a database and inform .env

With laravel 5 my .env file looks like:

APP_ENV=local
APP_DEBUG=true
APP_KEY=B0ST6bRoqxVJ2JtUNPtittJup6mRJef2

DB_HOST=127.0.0.1
DB_DATABASE=laravel_base
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=file
SESSION_DRIVER=file

When I try to seed the database I get an error:

   $ php artisan migrate --seed


  [PDOException]                             
  SQLSTATE[HY000] [2002] Connection refused 

How do I create a database so I can run my laravel application on my mac? I have postgres installed. The default for this application is mysql ('default' => 'mysql') in config/database.php. If I change it to 'default' => 'pgsql' I get a different error:

$ php artisan migrate --seed


[PDOException]         
could not find driver 

I don't really care if I have mysql or psql database, just want it to work. Mysql is the default though, so might be better to stick with that. What are the commands to set up mysql/psql databases for laravel projects?

4
  • What does the pgsql connection look like. Also is pgsql set as your default connecftion Commented Dec 27, 2015 at 21:17
  • $ psql psql: FATAL: database "connorleech" does not exist Commented Dec 27, 2015 at 21:20
  • In your laravel database.php file, what does pgsql => look like? and is 'default' => 'pgsql' set? Commented Dec 27, 2015 at 21:21
  • the default is set to mysql. When I change it to psql I get a different error: [PDOException] could not find driver. Commented Dec 27, 2015 at 21:24

1 Answer 1

1

You should make sure:

  • You have in your php.ini PDO PostgreSQL enabled (extension=php_pdo_pgsql.dll not starting with ;)
  • Set in .env DB_CONNECTION to pgsql (or default do pgsql in config/database.php depending what specific version of Laravel you use (5.0 or 5.1/5.2))

If you won't be able to make it work, you should think of installing Laravel Homestead that has everything needed to develop Laravel applications

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

Comments

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.