Laravel – Illuminate\Database\QueryException with message ‘SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘test.people’ doesn’t exist

laravel

i made a migration named persons while i want to import data useing tinker then error showing i made a migration named persons while i want to import data useing tinker then error showing Illuminate\Database\QueryException with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test.people' doesn't exist (SQL: selec

Best Answer

This error can be caused when your database table has not created correctly. You must to create your models and migration files first.

To create them you can run this command (for example):

 php artisan make:model People -m

Then, after all configurations in the People model class and in the migration file - run:

php artisan migrate 

This will create all the migration tables in the database. p.s. don't forget to check your .env file for the correct database name.

...
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=<your_database_name>
DB_USERNAME=<your_username>
DB_PASSWORD=<your_password>
 ...