Laravel 5.5错误基表或视图已存在:1050表“用户”已存在

  • Laravel版本:5.5.3
  • PHP版本:7.1
  • 数据库驱动程序和版本:MariaDB 10.1.26

C:/Users/user/code/blog/>php artisan migrate

[Illuminate\Database\QueryException]

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists (SQL: create table users (id int unsigned not null aut

o_increment primary key, name varchar(255) not null, email varchar(255) not null, password varchar(255) not null, remember_token varchar

(100) null, created_at timestamp null, updated_at timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci engine = InnoDB R

OW_FORMAT=DYNAMIC)

[PDOException]

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists

 C:/Users/user/code/blog/>laravel new website

C:/Users/user/code/blog/>php artisan make:migration create_lists_table --create=lists

C:/Users/user/code/blog/>php artisan migrate

它创建用户表并给出错误,但不创建列表表

回答:

我通过更改我的create_users_table.php解决了自己的问题

<?php

use Illuminate\Support\Facades\Schema;

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration

{

/**

* Run the migrations.

*

* @return void

*/

public function up()

{

Schema::dropIfExists('users');

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::dropIfExists('users');

}

}

以上是 Laravel 5.5错误基表或视图已存在:1050表“用户”已存在 的全部内容, 来源链接: utcz.com/qa/426149.html

回到顶部