i have mysql file. it has .sql extension. how to run that "mysql" file using php script? how is the script should be? the mysql file is already on the server, and i want开发者_开发百科 to run this query using php file which is placed on the same place with mysql file...
You could do this
$query=file_get_contents($file);
$mysqli->multi_query($query);
mysqli::multi_query can do the job.
the mysql file is already on the server
dun use PHP ....
Linux ???
install mysql client, and run a shell like
mysql -u root -ppassword -P port_number < any.sql
Windows ???
still need to install mysql client, repeat from above
if you don't have ssh access to the server, and don't have exec right
read/prepare again the mysql file by breaking multiple queries then execute one-by-one
精彩评论