What are the best practices for handling large SQL files during a server migration, especially when faced with server limitations on file size?

When faced with server limitations on file size during a server migration, it is best to break down the large SQL file into smaller chunks. This can be done by splitting the file into multiple smaller files based on table structure or by using tools like mysqldump with the --where option to export data in smaller batches. By breaking down the SQL file, you can avoid hitting file size limitations and ensure a smoother migration process.

// Sample PHP code to split a large SQL file into smaller chunks
$file = 'large_file.sql';
$lines = file($file);
$chunkSize = 1000; // Number of lines per chunk

for ($i = 0; $i < count($lines); $i += $chunkSize) {
    $chunk = array_slice($lines, $i, $chunkSize);
    $chunkFile = 'chunk_' . ($i / $chunkSize) . '.sql';
    file_put_contents($chunkFile, implode('', $chunk));
}