MySQL导出查询数据出现--secure-file-priv选项问题

一、问题描述

Windows平台的MySQL5.7.12版本使用以下命令导出查询结果到Excel文件时,会出现问题

select sid, sname, age from student
into outfile 'D:/Files/student.xlsx';
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

二、查明原因

通过查阅官方文档:https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html,可以知道导出导入文件的相关操作会受到全局变量secure-file-priv的限制,如load data命令、select ... into outfile ...语句、LOAD_FILE()函数等。

具体怎么影响如文档所说:

secure_file_priv may be set as follows:

If empty, the variable has no effect. This is not a secure setting.

If set to the name of a directory, the server limits import and export operations to work only with files in that directory. The directory must exist; the server 
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值