Laravel 迁移无效

Laravel migration not working

我尝试在 laravel

中实现默认的身份验证登录系统
      php artisan make:migration create_users_table
      Created Migration: 2016_03_10_115611_create_users_table

在 运行 上,上述命令仅创建迁移文件,而不创建表。 我也试过重新安装作曲家,但没有用

//In 2016_03_10_115611_create_users_table file
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
 /**
 * Run the migrations.
 *
 * @return void
 */
 public function up()
 {
    Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
    });
 }

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::drop('users');
}
}

在 运行

php artisan migrate 

花了一些时间才返回

[ErrorException]PDO::__construct(): MySQL server has gone away

感谢大家,我没有正确配置 .env 文件,所以它不起作用

你的 MySQL 版本是多少? 或者你还没有修改 .env

尝试 SQLite 并将设置数据库更改为 sqlite。我认为这个问题在 php 分机上。

首先你有运行这个命令来安装迁移

php artisan migrate:install

注意:- 如果您查看 database/migrations,将会有两个迁移文件

  1. 2014_10_12_000000_create_users_table.php
  2. 2014_10_12_100000_create_password_resets_table.php

    php artisan 迁移