ERROR 1290 (HY000): --secure-file-priv option

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

select concat('KILL ',id,';') from information_schema.processlist where user='root' into outfile '/tmp/test.txt';

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

查看官网:

1.如果secure_file_priv 的值为空的话,这个变量将不起作用;

2.如果secure_file_priv的值为路径的话,则mysql服务器将限制导入导出操作功能在这个设置的路径下使用。这个路径必须存在。

3.如果secure_file_priv的值设置为空的话,mysql服务器不能使用导出导入操作功能.但是,在mysql 5.7.6下是可以操作的。

所以,也就是说,要找到secure_file_priv这个变量,并且将其设置为我们想要存放数据的路径就可以了

mysql>  show global variables like '%secure%';  

+------------------+-------+

| Variable_name    | Value |

+------------------+-------+

| secure_auth      | ON    |

| secure_file_priv | NULL  |

+------------------+-------+

2 rows in set (0.01 sec)

 -- 限制mysqld 不允许导入导出

解决办法:

给这个参数指定目录,!有一点需要注意,那就是要确保你设置的路径mysql具有读写权限


[root@localhost tmp]# grep secure_file_priv  /usr/local/mysql5.6/my.cnf

secure_file_priv = /tmp


-- 限制mysqld的导入导出只能发生在/tmp/目录下

secure_file_priv=' '         -- 不对mysqld 的导入 导出做限制


重启mysql

[root@localhost tmp]# ps -ef|grep mysql

root      6115  5302  0 22:55 pts/2    00:00:00 /bin/sh /usr/local/mysql5.6/bin/mysqld_safe --defaults-file=/usr/local/mysql5.6/my.cnf

mysql     6638  6115  0 22:55 pts/2    00:00:00 /usr/local/mysql5.6/bin/mysqld --defaults-file=/usr/local/mysql5.6/my.cnf --basedir=/usr/local/mysql5.6 --datadir=/data/mysql3307/data --plugin-dir=/usr/local/mysql5.6/lib/plugin --user=mysql --log-error=/data/mysql3307/log/error.log --open-files-limit=65535 --pid-file=/data/mysql3307/log/git-server.pid --socket=/tmp/mysql3307.sock --port=3307


pkill mysql 


[root@localhost tmp]# /usr/local/mysql5.6/bin/mysqld_safe --defaults-file=/usr/local/mysql5.6/my.cnf &

[1] 6115

[root@localhost tmp]# 170821 22:55:15 mysqld_safe Logging to '/data/mysql3307/log/error.log'.

170821 22:55:15 mysqld_safe Starting mysqld daemon with databases from /data/mysql3307/data


mysql> show global variables like '%secure%';

+------------------+-------+

| Variable_name    | Value |

+------------------+-------+

| secure_auth      | ON    |

| secure_file_priv | /tmp/ |

+------------------+-------+

mysql> select concat('KILL ',id,';') from information_schema.processlist where user='root' into outfile '/tmp/test.txt';

Query OK, 1 row affected (0.00 sec)


[root@localhost tmp]# cat /tmp/test.txt 

KILL 1;




  通过information_schema.processlist表中的连接信息生成需要处理掉的MySQL连接的语句临时文件,然后执行临时文件中生成的指令。

复制代码 代码如下:


mysql> select concat('KILL ',id,';') from information_schema.processlist where user='root';

+------------------------+

| concat('KILL ',id,';') |

+------------------------+

| KILL 3101;             |

| KILL 2946;             |

+------------------------+

2 rows in set (0.00 sec)

 

mysql>select concat('KILL ',id,';') from information_schema.processlist where user='root' into outfile '/tmp/a.txt';

Query OK, 2 rows affected (0.00 sec)

 

mysql>source /tmp/a.txt;

Query OK, 0 rows affected (0.00 sec)


参考链接

http://www.jb51.net/article/65718.htm



 本文转自 wjw555 51CTO博客,原文链接:http://blog.51cto.com/wujianwei/1958223

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
4月前
|
关系型数据库 MySQL 数据库
Mysql-错误处理: Found option without preceding group in config file
Mysql-错误处理: Found option without preceding group in config file
143 0
|
移动开发 JSON 关系型数据库
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
|
关系型数据库 MySQL 数据安全/隐私保护
MySQL:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
MySQL:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
102 0
|
SQL 安全 关系型数据库
解决bug:the --secure-file-priv option so it cannot execute this statement
解决bug:the --secure-file-priv option so it cannot execute this statement
465 0
解决bug:the --secure-file-priv option so it cannot execute this statement
|
关系型数据库 MySQL SQL
[解决] Error Code: 1044. Access denied for user 'root'@'%' to database
今天在测试集群用的mysql上,遇到个权限的问题: SQLException : SQL state: 42000 com.mysql.jdbc.exceptions.
5122 0