配置:–secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled

2020年1月8日 | 分类: 未分类

在 error.log 中出现:

secure-file-priv2020-01-08T04:14:12.407602Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled

[提示]–secure-file-priv被设置成NULL,有关数据导入导出操作被禁止。

参考:https://www.douban.com/note/522105222/
参考:http://www.liuhaihua.cn/archives/503980.html

secure-file-priv

参数定义:是限制LOAD_FILE和LOAD DATA和SELECT … ,INTO OUTFILE报表到指定的目录。
默认值有:empty、dirname、NULL,正确的意思就是:留空、指定路径、NULL值。
empty 就是留空,会转成默认值,也就是platform-specific
设置路径会要求该路径其他系统用户不能读,而且不能获取到你的MySQL数据库目录。
NULL就是空,也是禁用的意思。

参考:https://blog.csdn.net/liu16659/article/details/84581394
参考:https://blog.csdn.net/qq_31518899/article/details/75662090

在配置文件中,设置secure-file-priv为某个路径即可。

创建目录:

cp -r /var/log/mysql /var/tmp/mysql

设置:

secure-file-priv = /var/tmp/mysql

查看:

mysql -v -p
Enter password:
...
mysql> show variables like '%secure_file_priv%';
+------------------+--------------------------------------------------+
| Variable_name    | Value                                            |
+------------------+--------------------------------------------------+
| secure_file_priv | /var/tmp/mysql                                   |
+------------------+--------------------------------------------------+
1 row in set, 1 warning (0.00 sec)

发现:

2020-01-08T04:34:04.757699Z 0 [Warning] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a different directory.

参考:http://geodatawrangler.lazym8.com/blog/2017/02/16/secure-file-priv

设置:

secure-file-priv = 

发现:

2020-01-08T04:46:37.887633Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.