mysql5.7导出数据提示--secure-file-priv选项问题的解决方法
mysql可使用 into outfile 参数把表中数据导出到csv,例如可用以下命令把user表的数据导出到user.csv
select * from user into outfile '/tmp/user.csv' fields terminated by ',' optionally enclosed by '"' lines terminated by '\r\n';
执行后,user表的数据会导出到/tmp/user.csv。
参数说明:
into outfile ‘导出的目录和文件名’
指定导出的目录和文件名
fields terminated by ‘字段间分隔符’
定义字段间的分隔符
optionally enclosed by ‘字段包围符’
定义包围字段的字符(数值型字段无效)
lines terminated by ‘行间分隔符’
定义每行的分隔符
问题分析
以上命令在mysql5.6下运行没有问题,但在mysql5.7下运行则出现了以下错误。
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
查看官方文档,secure_file_priv参数用于限制LOAD DATA, SELECT …OUTFILE, LOAD_FILE()传到哪个指定目录。
secure_file_priv 为 NULL 时,表示限制mysqld不允许导入或导出。
secure_file_priv 为 /tmp 时,表示限制mysqld只能在/tmp目录中执行导入导出,其他目录不能执行。
secure_file_priv 没有值时,表示不限制mysqld在任意目录的导入导出。
查看 secure_file_priv 的值,默认为NULL,表示限制不能导入导出。
mysql> show global variables like '%secure_file_priv%';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| secure_file_priv | NULL |
+------------------+-------+
1 row in set (0.00 sec)
因为 secure_file_priv 参数是只读参数,不能使用set global命令修改。
mysql> set global secure_file_priv='';
ERROR 1238 (HY000): Variable 'secure_file_priv' is a read only variable
解决方法
打开my.cnf 或 my.ini,加入以下语句后重启mysql。
secure_file_priv=''
查看secure_file_priv修改后的值
mysql> show global variables like '%secure_file_priv%';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| secure_file_priv | |
+------------------+-------+
1 row in set (0.00 sec)
修改后再次执行,成功导出。
mysql> select * from user into outfile '/tmp/user.csv' fields terminated by ',' optionally enclosed by '"' lines terminated by '\r\n';
Query OK, 15 rows affected (0.00 sec)
原文链接:https://blog.csdn.net/fdipzone/article/details/78634992
mysql5.7导出数据提示--secure-file-priv选项问题的解决方法的更多相关文章
- Mongo导出数据文件导致错误 Got signal: 6 (Aborted)解决方法
一哥们要导出一个数据表的数据,结果导出一半,硬盘不够用,卡死了, 然后重启主机,导致mongo启动后进程自动死掉, 报错如下. Mon Oct 28 10:39:02.270 [initandlist ...
- Oracle数据导入导出imp/exp sp2-0734:未知的命令开头'imp...解决方法
Oracle数据导入导出imp/exp sp2-0734:未知的命令开头'imp...解决方法 sp2-0734:未知的命令开头'imp 忽略了剩余行默认分类 www.2cto.com 应该 ...
- Npoi Web 项目中(XSSFWorkbook) 导出出现无法访问已关闭的流的解决方法
原本在CS项目中用的好好的在BS项目中既然提示我导出出现无法访问已关闭的流的解决方法 比较郁闷经过研究 终于解决了先将方法发出来 让遇到此问题的筒子们以作参考 //新建类 重写Npoi流方法 publ ...
- Parse error: syntax error, unexpected end of file in *.php on line * 解决方法
Parse error: syntax error, unexpected end of file in *.php on line * 解决方法 这篇文章主要介绍了PHP错误Parse erro ...
- IntelliJ IDEA提示URI is not registered几种解决方法
IntelliJ IDEA提示URI is not registered几种解决方法使用IntelliJ IDEA (以下简称IDEA)导入项目或是在maven生成 archetype时候,如果提示 ...
- safari无法调试iphone提示“无可检查的应用程序”的解决方法
iphone上打开safari,随便访问一个网站,mac上通过Safari的开发,我的iphone是可以看到的.如果打开APP,就提示“无可检查的应用程序”. 解决方法 使用XCode运行我们的App ...
- 安装office2010提示要安装MSXML6.10.1129.0解决方法
系统win7 32位 安装office2010出现了错误,提示要安装MSXML6.10.1129.0解决方法 1.下载MSXML6.10.1129.0进行安装 2.若本机已安装过不管用: a.在运行里 ...
- 安装JDK时提示 IllegalArgumentException:Invalid characters in hostname的解决方法
今天在windows7_x64上安装JDK的时候提示IllegalArgumentException:Invalid characters in hostname, 解决方法: 1.打开[控制面板\系 ...
- InnoDB: Operating system error number 87 in a file operation. 错误87的解决方法
InnoDB: Operating system error number 87 in a file operation. 错误87的解决方法 140628 8:10:48 [Note] Plugi ...
随机推荐
- DFS-B - Dr. Evil Underscores
B - Dr. Evil Underscores Today, as a friendship gift, Bakry gave Badawy nn integers a1,a2,…,ana1,a2, ...
- pip问题:Traceback (most recent call last): File "/usr/bin/pip", line 9, in
源作者blog https://blog.csdn.net/vmxhc1314/article/details/81869676 编辑提示的文件,进行更改即可. 解决方法: 将 /usr/bin/pi ...
- poj1000-1009小结
poj1000-1009小结 poj1000-1009小结 poj1000 AB poj1001 Exponentiation poj1002 poj1003 poj1004 Financial Ma ...
- gulp 对js\css进行md5 加密
有的服务器为了网站加载速度,会做服务器缓存,这样就会出现代码出现引用地址没变,新代码不生效,而我们又希望新代码可以及时生效,这样我们就需要避免缓存,当然也有很多方法,本文只介绍使用gulp-rev(对 ...
- create_function()代码注入
00x00create_function()函数的简介 适用范围:PHP 4> = 4.0.1,PHP 5,PHP 7 功能:根据传递的参数创建匿名函数,并为其返回唯一名称. 语法: creat ...
- PIE-SDK For C++栅格数据集的读取
1.功能简介 栅格数据包含很多信息,在数据的运用中需要对数据的信息进行读取,目前PIE SDK支持多种数据格式的数据读取,下面对栅格数据格式的数据读取功能进行介绍. 2.功能实现说明 2.1 实现思路 ...
- Python标准库之shelve模块(序列化与反序列化)
shelve模块是一个简单的key,value将内存数据通过文件持久化的模块,可以持久化任何picklel可支持的Python数据格式. 序列化 序列化源代码: import shelve impor ...
- C++-POJ2975-Nim
题目把Nim游戏为什么可以取异或和讲解得十分清楚,建议多读几次,理解一下 再一个,可以把每次异或视为一次取数,因此(k[i]^sg)<k[i]即为一种可行操作 /* Nim is a 2-pla ...
- centos下配置mongodb定期备份
https://brickyang.github.io/2017/03/02/Linux-%E8%87%AA%E5%8A%A8%E5%A4%87%E4%BB%BD-MongoDB/ 1.创建备份脚本 ...
- java继承与多态课后作业
1.动手实验 源码 class Grandparent { public Grandparent() { System.out.println("GrandPar ...