bestmomo / laravel5-example

Simple laravel5 example for tutorial
MIT License
1.2k stars 568 forks source link

instructions for database connection #41

Closed connor11528 closed 8 years ago

connor11528 commented 8 years ago

Hi there,

I'm new to laravel, mostly write node.js/javascript. I have a mac, not sure how to create a database.

Ran

$ php artisan migrate --seed

  [PDOException]                                    
  SQLSTATE[HY000] [2002] No such file or directory  

Then I changed the .env file to DB_HOST=127.0.0.1 as mentioned in this SO post. Now I get a different error:

$ php artisan migrate --seed

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

I have not run any mysql or postgres commands yet. What commands do I need to run in order to get rid of the Connection refused error and populate the database?

bestmomo commented 8 years ago

Hi,

Why not installing homestead ?

connor11528 commented 8 years ago

Yeah I need to do that. What are the steps for launching this project with homestead? I have the command line tool installed:

$ homestead --version
Laravel Homestead version 3.0.1
bestmomo commented 8 years ago

I never used homestead, I am on Windows and it's really difficult to use in on this system, so I have no experience on it. You should ask your question on Laracast forum.

squrlman commented 8 years ago

hi, hope this helps. if you are using composer use: $ php artisan make:migration name and go to database/migrations and you will see the migration u created (name). run this: $ php artisan migrate but before doing all the above you need to edit ur config/database.php file, look for 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ], and change database,username,and password accordingly. and also do same for the .env file.

connor11528 commented 8 years ago

Ok I'll figure this out. General laravel question, not specific to this project!