php - Laravel 5: Database Migrations (Help!) -
some useful information:
- im running on os x (el capitan beta)
- im using xampp
- i've installed laravel 5 , can confirm works.
here migration file:
<?php use illuminate\database\schema\blueprint; use illuminate\database\migrations\migration; class createuserstable extends migration { /** * run migrations. * * @return void */ public function up() { schema::create('users', function(blueprint $table) { $table->increments('id'); $table->string('email'); $table->string('username'); $table->string('password'); $table->string('first_name')->nullable(); $table->string('last_name')->nullable(); $table->string('remember_token')->nullable(); $table->timestamps(); }); } /** * reverse migrations. * * @return void */ public function down() { schema::drop('users'); } }
my .env file
app_env=local app_debug=true app_key=tvzwp6tllrwk4zxdgdeudpoznvxxyenz db_host=localhost db_database=users db_username=root db_password= cache_driver=file session_driver=file queue_driver=sync mail_driver=smtp mail_host=mailtrap.io mail_port=2525 mail_username=null mail_password=null mail_encryption=null
my database.php file
<?php return [ /* |-------------------------------------------------------------------------- | pdo fetch style |-------------------------------------------------------------------------- | | default, database results returned instances of php | stdclass object; however, may desire retrieve records in | array format simplicity. here can tweak fetch style. | */ 'fetch' => pdo::fetch_class, /* |-------------------------------------------------------------------------- | default database connection name |-------------------------------------------------------------------------- | | here may specify of database connections below wish | use default connection database work. of course | may use many connections @ once using database library. | */ 'default' => env('db_connection', 'mysql'), /* |-------------------------------------------------------------------------- | database connections |-------------------------------------------------------------------------- | | here each of database connections setup application. | of course, examples of configuring each database platform | supported laravel shown below make development simple. | | | database work in laravel done through php pdo facilities | make sure have driver particular database of | choice installed on machine before begin development. | */ 'connections' => [ 'sqlite' => [ 'driver' => 'sqlite', 'database' => storage_path('database.sqlite'), 'prefix' => '', ], '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, ], 'pgsql' => [ 'driver' => 'pgsql', 'host' => env('db_host', 'localhost'), 'database' => env('db_database', 'forge'), 'username' => env('db_username', 'forge'), 'password' => env('db_password', ''), 'charset' => 'utf8', 'prefix' => '', 'schema' => 'public', ], 'sqlsrv' => [ 'driver' => 'sqlsrv', 'host' => env('db_host', 'localhost'), 'database' => env('db_database', 'forge'), 'username' => env('db_username', 'forge'), 'password' => env('db_password', ''), 'charset' => 'utf8', 'prefix' => '', ], ], /* |-------------------------------------------------------------------------- | migration repository table |-------------------------------------------------------------------------- | | table keeps track of migrations have run | application. using information, can determine of | migrations on disk haven't been run in database. | */ 'migrations' => 'migrations', /* |-------------------------------------------------------------------------- | redis databases |-------------------------------------------------------------------------- | | redis open source, fast, , advanced key-value store | provides richer set of commands typical key-value systems | such apc or memcached. laravel makes easy dig right in. | */ 'redis' => [ 'cluster' => false, 'default' => [ 'host' => 'localhost', 'port' => 3306, 'database' => 0, ], ], ];
when run 'php artisan migrate' on terminal a
[pdoexception] sqlstate[hy000] [2002] no such file or directory
my database connection credintels are: host is: 'localhost' db username is: 'root' db password is: ''
i have no tables in database, want run migration create table.
thanks in advance
as you're connecting localhost, pdo trying connect database using unix socket file doesn't exist. replace localhost 127.0.0.1 , connect database using tcp connection, should fix issue.
Comments
Post a Comment