1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > MYSQL导出数据报错ERROR 1290 (HY000) 和 ERROR 1 (HY000)

MYSQL导出数据报错ERROR 1290 (HY000) 和 ERROR 1 (HY000)

时间:2023-03-30 07:47:43

相关推荐

MYSQL导出数据报错ERROR 1290 (HY000) 和 ERROR 1 (HY000)

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

mysql可使用 into outfile 参数把某表中数据导出到一个文件中,例如可用以下命令把AAA 表的数据导出到test_out.txt'

select * from AAA into outfile '/home/test/Desktop/test_out.txt';

执行以上mysql语句后报错:The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

用以下mysql语句 查看secure_file_priv 对应的值

查看 secure_file_priv 的值,默认为NULL,表示限制不能导入导出。

查看官方文档,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 参数是只读参数,不能使用set global命令修改。

解决方法

打开fmy.ini,加入以下语句后重启mysql。

修改后再次执行,可以成功导出。

问题2:

执行命令select * from AAA into outfile '/home/test/Desktop/test_out.txt';时,报错如下:

ERROR 1 (HY000): Can't create/write to file '/home/test/Desktop/test_out.txt' (OS errno 13 - Permission denied)

是权限的问题,将文件导出到tmp目录下是可以的。

在/web目录下新建一个tt的目录,并赋予777的权限

chown –R 777 /web/tt

因为select into outfile的命令是mysql的daemon来负责写文件操作的,需要对文件具有写的权限,而/web目录的权限为755,mysql不具有对文件写的权限,所以就报不能create/write了,而/tmp是777的权限,所以也就是为什么能够写入的原因

参考:

MYSQL导入数据出现ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it_jav0a0的博客-CSDN博客

ERROR 1 (HY000): Can't create/write to file '/web/file.txt' (Errcode: 13) - 言止予思 - 博客园

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。