本文介绍了Laravel 5.5 错误基表或视图已存在:1050 表“用户"已存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
规格:
- Laravel 版本:5.5.3
- PHP 版本:7.1
- 数据库驱动程序和版本:MariaDB 10.1.26
说明:
C:/Users/user/code/blog/>php artisan migrate
[IlluminateDatabaseQueryException]
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
问题
它创建用户表并给出错误但不创建列表表
It Creates users table and give error but not creating lists table
推荐答案
我自己解决了我的问题通过更改我的 create_users_table.php
I Solved My Problem Myself by Changing My create_users_table.php
<?php
use IlluminateSupportFacadesSchema;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateDatabaseMigrationsMigration;
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 表“用户"已存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!