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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INTO OUTFILE Directory

Status
Not open for further replies.

DANDARSMASH

Programmer
May 17, 2013
17
0
0
US
Hello.

I'm doing an SQL query and converting it to XLS. When I run the query on the localhost DB, The file outputs to the specified location at C:/tmp/myfile.csv. However, when I run the query on the live DB, it outputs to the DB server at /home/mysql/csv/myfile.csv. As result, I can only see the file if I SSH into the server machine. Is there a way to get the the live file to export to my local machine? Pointing it to C:/tmp/myfile.csv has no result.

SQL:
SELECT p.paymentdate, p.filenumber, p.paymentstatus, p.paymentamount, d.fullname, d.address, d.city, d.state, d.zip, d.makepayabletoname, d.makepayabletoaddress, d.makepayabletocity, d.makepayabletostate, d.makepayabletozip, d.emailaddress 
FROM payments p, dbase d 
WHERE p.filenumber = d.filenumber 
AND p.paymentstatus = "pending" 
AND p.paymentdate = curdate() 
INTO OUTFILE "C:/tmp/text.csv" 
FIELDS TERMINATED BY  "," 
ENCLOSED BY "\"" 
ENCLOSED BY "\ " 
ESCAPED BY "\ \ " 
LINES TERMINATED BY "\n"

URL]


"Any sufficiently advanced technology is indistinguishable from magic" [Arthur C. Clark]</td></tr></table>
 
if you have mysql installed locally, you can use that to connect to the remote host and achieve the desired result
from a command line:
c:\>mysql -h<host> -u<user> -p -e"Select statement" database [table optionally] > c:\tmp\myfile.csv

the password will be requested before the query will execute.

if you have the ,ysql workbench installed you will need to cd into its installed directory to run the command as it probably wont have registered the path to mysql.exe (found in the workbench folder).

firewalls and user hosts permissions may also hinder your success.


Cheers
K

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top