Specifications:
Laravel Version: 5.4
PHP Version: 7.0.9
Composer version 1.9.0
XAMP
Description:
In Connection.php line 647:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘users’ already exists (SQL: create table users
(
int unsigned not null auto_increment primary key,
idname
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
tim
estamp null) default character set utf8mb4 collate utf8mb4_unicode_ci)
In Connection.php line 449:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘users’ already exists
Problem:
I have created models and tables of user and Product. It successfully created both migrations and tables but failed to migrate on phpmyadmin sql.
Steps I tried:
I have dropped all database and recreated it but still it gives error.
I have also used tinker but error is same.
code:
<?php
use IlluminateSupportFacadesSchema;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateDatabaseMigrationsMigration;
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::dropIfExists('users');
}
}
3
Answers
In your
users
table migration file add this line inup()
methodLike this
Check your migration table if the “User” Table is recorded there, delete it and then do a single migration using this artisan command
Or Do reset the migration using the following and then migrate again