Solution 1
If you are running your PHP on a Linux system, you can try using the 'mysql' command itself. However please note that your PHP installation has the permission to run "system" commands, like system(), exec() etc.
So here is what I mean to say:
system("mysql -U{db_user_name} -h{db_host} -P{db_password} < {full_path_to_your_sql_file}");
Please replace,
{db_user_name} with the DB username,
{db_host} with the DB host,
{db_password} with the DB password,
{full_path_to_your_sql_file} with the path to your SQL file.
And this of course requires the SQL file to be uploaded.
Solution 2:
Read the SQL file line by line and while reading execute each statement using PHP's standard MySQL library. Something like:
$arrFile = file("full_path_to_sql_file.sql", FILE_IGNORE_NEW_LINES);
foreach ($arrFile as $q) {
mysql_query($q);
}
However, this might not be as simple as it seems. If your SQL file has comments and other .sql specific statements, you might need to put checks to ignore them. Or better if the SQL file contains nothing but SQL statements.