fsockopen() might be able to do this, but it wouldn't be pretty.
use something like the php function exec() to call a shell script to load the mysql client application and import the data.
filename: test.sql
###############################
use test;
show tables;
###############################
filename: test.sh
###############################
mysql --host=127.0.0.1 -u username --password=password < test.sql
###############################
make the shell script readable to whatever user apache is running at (likely user nobody.nobody) using "chmod o+rx
in the php file:
<?
exec("/path/to/shell/script");
?>
standard security issues apply. if apache can read the password likely everyone who can telnet to the machine php is running on can also read the password. you could move the shell script into the php script and run the commands that way, it'll simplify the files but still has security issues.