I am using MySQL and would like the results of the following query to be stored in a csv file locally on my machine:
我正在使用MySQL,并希望将以下查询的结果存储在我的机器本地的csv文件中:
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.
我搜索过该文件但它无法位于磁盘上的任何位置,因此它不在“data”目录中。
1 个解决方案
#1
5
Be default it stored in the MySQL's data directory. And you can check your data directory by command:
默认情况下它存储在MySQL的数据目录中。您可以通过命令检查数据目录:
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' ;
#1
5
Be default it stored in the MySQL's data directory. And you can check your data directory by command:
默认情况下它存储在MySQL的数据目录中。您可以通过命令检查数据目录:
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' ;