What alternative methods can be used to execute a SQL file with PHP other than reading and executing its content directly?

When executing a SQL file with PHP, an alternative method to reading and executing its content directly is to use the `exec()` function to run the `mysql` command line tool. This allows you to pass the SQL file as an argument to `mysql` for execution.

<?php
// Define the path to the SQL file
$sqlFile = '/path/to/your/sql/file.sql';

// Define the database connection details
$host = 'localhost';
$user = 'username';
$password = 'password';
$database = 'database_name';

// Execute the SQL file using the mysql command line tool
exec("mysql -h $host -u $user -p$password $database < $sqlFile");
?>