Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exporting mysql data to text file

Status
Not open for further replies.

richclever

IS-IT--Management
Oct 5, 2000
127
FR
Hi,

I want to export some data from one database to another but unfortunately my host won't allow inbound or outbound connections so I can't connect to the remote host.

What I thought I'd do to get around the problem is to write the mysql commands to a text file which can then be run on the remote server (I can ftp it). How do I send the mysql statements to an external text file?

For example, if I have

$query1 = "insert into listingsDB (ID,user_ID,Title,expiration,notes,creation_date,last_modified,hitcount,featured,leaseb,depno,active) values ('$l','444','$title[$count]','2006-01-01',' ','2005-01-01','NULL','1','no','no','$departmentid[$i]','yes')" ;
$result1 = @mysql_query ($query1);

How do I write this into a mysql text file (obviously it will need to have the data contained in the variables).

Thanks a lot,
Richard
 
richclever,

I must be missing something about your question. Couldn't you just code it as a mysql_query in a PHP script, FTP upload to your remote host, and then execute the PHP script with a browser? Since the mysql_query will originate at localhost, you should be able to access the MySQL database.

Wishdiak
A+, Network+, Security+, MCSA: Security 2003
 
The script needs to work as a cronjob (the php does that on the source server to get the mysql data entries) then it needs to ftp to the destination server and run. I was going to have a php cron job (or bash) that processes the sql data file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top