我正在尝试在laravel 5.8上使用Migration,但我收到此错误消息
C:\wamp\www\work_p\laravel\lvl1>php artisan migrate
Migrating: 2014_10_12_000000_create_users_table
Illuminate\Database\QueryException : SQLSTATE[42S01]: Base table or view alr
eady exists: 1050 Table 'users' already exists (SQL: create table `users` (`id`
bigint unsigned not null auto_increment primary key, `name` varchar(191) not nul
l, `email` varchar(191) not null, `email_verified_at` timestamp null, `password`
varchar(191) not null, `remember_token` varchar(100) null, `created_at` timesta
mp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf
8mb4_unicode_ci')
at C:\wamp\www\work_p\laravel\lvl1\vendor\laravel\framework\src\Illuminate\Dat
abase\Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll
format the error
661| // message to include the bindings with SQL, which will make th
is exception a
662| // lot more helpful to the developer instead of just the databa
se's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 PDOException::("SQLSTATE[42S01]: Base table or view already exists: 1050 T
able 'users' already exists")
C:\wamp\www\work_p\laravel\lvl1\vendor\laravel\framework\src\Illuminate\Da
tabase\Connection.php:458
2 PDOStatement::execute()
C:\wamp\www\work_p\laravel\lvl1\vendor\laravel\framework\src\Illuminate\Da
tabase\Connection.php:458
Please use the argument -v to see more details.
我在这里找到的所有解决方案都说我必须删除表格;
但是我的表上没有数据,用户表和所有其他表上都有数据。没有删除表,有没有解决此错误的方法? 我确实尝试过使用此解决方案
public function boot()
{
Schema::defaultStringLength(191);
}
问题仍然存在
答案 0 :(得分:1)
如果您不想专门运行该迁移,请在数据库上运行此查询
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (NULL, '2014_10_12_000000_create_users_table', '1');