I can't seem to find this, I've tried searching and so far, nothing
I have a MySQL dump file being transferred between servers, on the new server I want to run a script that imports it into a MySQL...it can't be done using a prompt, since permissions don't allow it
is there anything built into PHP that can do this? I've tried writing a few scripts and keep coming close, but nothing seems to be working
how can I import a .sql file with PHP
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: how can I import a .sql file with PHP
Is it an SQL or CSV file? If it is SQL then open, read it and run the queries. If it is CSV then use "LOAD DATA INFILE".
(#10850)
Re: how can I import a .sql file with PHP
it's an SQLarborint wrote:Is it an SQL or CSV file? If it is SQL then open, read it and run the queries. If it is CSV then use "LOAD DATA INFILE".
I finally found a script, and it is:
Code: Select all
$sql = explode(';', file_get_contents('healthm.sql'));
foreach ($sql as $key => $val) {
mysql_query($val);
}