MySQL导出CSV文件报错secure-file-priv权限受限mac

MySQL导出文件遇到secure-file-priv报错

前两天在电脑上安装了MySQL 8.0.18,在尝试从数据库导出csv文件时,遇到了以下报错:

ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

secure-file-priv资料查询

上网一搜发现报错原因和secure-file-priv的值有关,secure-file-priv参数是用来限制mysql导入导出到哪个目录的

查阅官方文档找到secure-file-priv的值有以下几种情况:

[外链图片转存中…(img-TKY9txDb-1572537802321)]

而使用命令 show variables like "%secu%";检查secure-file-priv的值,发现本地secure_file_priv的值设置的是NULL,那么就需要将secure_file_priv的值设置为空字符串或者dirname才能导出文件。

[外链图片转存中…(img-A9za5MJP-1572537802323)]

解决办法

那么接着问题来了,在哪里设置secure-file-priv的值呢?

不能直接设置,必须要在my.cnf文件里设置(mac在my.cnf)。

那么my.cnf文件在哪里呢?

在下面3个关键目录中使用find命令全部搜了一遍也没有找到my.cnf文件,没有办法只有在网上重新找了一个my.cnf文件。

/etc
/usr/local/mysql/support-files
/usr/local/mysql-8.0.18-macos10.14-x86_64/support-files

在找到my.cnf后,进入/etc目录下,使用sudo vim my.cnf命令新建my.cnf文件,并将以下内容添加到my.cnf文件中。

# Example MySQL config file for medium systems.  
  #  
  # This is for a system with little memory (32M - 64M) where MySQL plays  
  # an important part, or systems up to 128M where MySQL is used together with  
  # other programs (such as a web server)  
  #  
  # MySQL programs look for option files in a set of  
  # locations which depend on the deployment platform.  
  # You can copy this option file to one of those  
  # locations. For information about these locations, see:  
  # http://dev.mysql.c
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值