SQL到outfile-文件存储在哪里? (MySQL,Windows) [英] SQL into outfile - where is the file stored? (MySQL, Windows)
本文介绍了SQL到outfile-文件存储在哪里? (MySQL,Windows)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用MySQL,并希望将以下查询的结果存储在本机本地的CSV文件中:
I am using MySQL and would like the results of the following query to be stored in a csv file locally on my machine:
SELECT * INTO OUTFILE 'mysqlresults.csv' FIELDS TERMINATED BY ','OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM table;
我已经搜索了该文件,但该文件找不到磁盘上的任何位置,因此它不在数据"目录中.
I have searched for the file and it could not be located anywhere on the disk so it is not in the 'data' directory.
推荐答案
默认情况下,它存储在MySQL的数据目录中. 您可以通过以下命令检查数据目录:
Be default it stored in the MySQL's data directory. And you can check your data directory by command:
show variables like 'datadir';
您无法使用在远程服务器上运行的此命令将其存储在本地,您需要从服务器下载文件.
You can't store it locally with this command running on remote server, you need to download the file from the server.
您也可以使用以下命令:
You can also use this command:
SELECT * FROM table INTO OUTFILE 'mysqlresults.csv' FIELDS TERMINATED BY ','OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' ;
这篇关于SQL到outfile-文件存储在哪里? (MySQL,Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文