如何在windows机器mysql 8.0中将查询结果导出到csv中?

gywdnpxw  于 2021-08-01  发布在  Java
关注(0)|答案(1)|浏览(287)

我正在尝试将查询结果导出到位置 C:\Users\useName\Desktop\locate 使用查询

select*from  table into outfile 'C:\\Users\\userName\\Desktop\\locate\\ans.csv' 
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';

它正在产生错误

'   Error Code: 1. Can't create/write to file 'C:\Users\userName\Desktop\locate\ans.csv' (OS errno 17 - File exists)    0.000 sec

虽然当我尝试使用mysql 8.0工作台手动使用gui按钮导出时,我可以导出它,但是我想使用query来完成!我只想把它保存到特定的位置!!
编辑1:

Error Code: 1. Can't create/write to file 'C:\Users\userName\Desktop\testR\ans1.csv' (OS errno 13 - Permission denied)  0.000 sec
d4so4syb

d4so4syb1#

以下是解决以下错误的步骤:

1)Press Windows+R
2)Type services.msc and hit enter
3)Search for MySQL service.
4)Right click on the service.
5)Go to properties.
6)Then go to Log On
7)set log on as local system account
8) restart the service.

砰!!你可以去任何你有权限写入文件的地方。
对于像我这样的新人,以下是重新启动服务的步骤:

1)Press Windows+R
    2)Type services.msc and hit enter
    3)Search for MySQL service.
    4)Select it then on left side you see option to restart ,hit it!!

相关问题