Debug School

rakesh kumar
rakesh kumar

Posted on

Laravel: Base table or view already exists: 1050 Table 'users' already exists

base-table-or-view-already-exists-1050-table-payments-alread
Error:
$ 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(255) not nul
l, `email` varchar(255) not null, `email_verified_at` timestamp null, `password`
 varchar(255) 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')
Enter fullscreen mode Exit fullscreen mode

Image description

Solution:

If you are on Laravel 5.5 you can do php artisan migrate:fresh. This command will drop all tables und then create them again. I hope it helps.

================= OR==============================

If you want to recreate the table,

run php migrate:rollback 
Enter fullscreen mode Exit fullscreen mode

first to delete the existing one. This command will run the down() method in the migration.

Then run php migrate to create the table again.

Top comments (0)