Normally we use
db:seed in Laravel by faker data. However, today, I will show you how to migrate SQL dump file in Laravel DB Seeder.
Run migration command-
php artisan migrate
Download your dump file and paste into
- database -- seeds --- source ---- dump_file
database/seeds/DatabaseSeeder.php file and include the dump file to migrate into db inside the
ini_set('memory_limit', '-1'); \DB::unprepared(file_get_contents(__dir__ . '/source/dump_file'));
Note: You can use
.sql file in the same way also. In that case, you just need to adjust the file extension.
Finally, run the following command-
php artisan db:seed
It should populate data from your
dump_file to your database now.