开发者

run mysql.sql using php

开发者 https://www.devze.com 2023-02-14 02:04 出处:网络
i have mysql file. it has .sql extension. how to runthat \"mysql\" file using php script? how is the script should be?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消