设为首页 加入收藏

TOP

mysqldump: Got error: 1290及secure-file-priv option 解决方法
2017-08-19 10:24:30 】 浏览:9103
Tags:mysqldump: Got error: 1290 secure-file-priv option 解决 方法

今天有个网友问,在用mysqldump备份时候遇到1290的错误
下面是是我模拟他的报错信息


[root@potato Desktop]# mysqldump -uroot -proot -S /tmp/mysql.sock --tab=/data/mysql/mytest_3306/data/backup lala
Warning: Using a password on the command line interface can be insecure.
mysqldump: Got error: 1290: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement when executing 'SELECT INTO OUTFILE'


可以很清楚地从提示看到是因为mysql服务启用了--secure-file-priv,所以才无法执行。
那么--secure-file-priv又是什么东东,应该如何解决才能是它可以备份呢?
 --secure-file-priv=name :
Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files within specified directory
可以看到secure-file-priv参数是用来限制LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE()传到哪个指定目录的。
当secure_file_priv的值为null ,表示限制mysqld 不允许导入|导出
当secure_file_priv的值为/tmp/ ,表示限制mysqld 的导入|导出只能发生在/tmp/目录下
当secure_file_priv的值没有具体值时,表示不对mysqld 的导入|导出做限制


查看数据库当前该参数的值
root@localhost:mysql.sock  00:14:52 [(none)]>show global variables like '%secure%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| secure_auth      | ON    |
| secure_file_priv | NULL  |
+------------------+-------+
2 rows in set (0.00 sec)


清楚地看到secure_file_priv 的值是NULL,说明此时限制导入导出的
所以应该改变该参数
可是查看了mysql.cnf中居然没有对这个参数进行设定,就说明这个参数默认便是null
所以再mysql.cnf中的[mysqld]加入secure_file_priv = 
再重启mysql服务


然后再查一下此时参数的值
root@localhost:mysql.sock  00:28:30 [(none)]>show global variables like '%secure%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| secure_auth      | ON    |
| secure_file_priv |      |
+------------------+-------+
2 rows in set (0.00 sec)
已经是我们要的结果


开始进行导出
[root@potato Desktop]# mysqldump -uroot -proot -S /tmp/mysql.sock --tab=/data/mysql/mytest_3306/data/backup lala
Warning: Using a password on the command line interface can be insecure.
可以看到成功了


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇mysqldump: Error: Binlogging on.. 下一篇MySQL复制的实现

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目