这篇文章主要介绍“怎么解决数据库报错ERROR 1290问题”,在日常操作中,相信很多人在怎么解决数据库报错ERROR 1290问题问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么解决数据库报错ERROR 1290问题”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
 
在使用SELECT...INTO OUTPUT导出数据时出现如下的报错:
 
root@localhost [team]>select * from team.player into outfile "/tmp/sql/player.txt";
 
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
 
通过报错的提示可以发现是由于secure-file-priv变量的设置所引起的,查看该变量的设置,默认的路径是/var/lib/mysql-files/
 
root@localhost [team]>show variables like '%secure%';
 
+--------------------------+-----------------------+
 
| Variable_name        | Value           |
 
+--------------------------+-----------------------+
 
| require_secure_transport | OFF            |
 
| secure_auth         | ON             |
 
| secure_file_priv     | /var/lib/mysql-files/|
 
+--------------------------+-----------------------+
 
3 rows in set (0.01 sec)
 
说明:
 
secure_file_prive=null   限制mysqld 不允许导入导出
 
secure_file_priv=/var/lib/mysql-files/   限制mysqld的导入导出只能发生在/var/lib/mysql-files/目录下
 
secure_file_priv=' '     不对mysqld的导入导出做限制
 
解决方法:
 
修改secure_file_prive的值或者是按照默认的路径进行导出;
 
windows下在my.ini文件 [mysqld]节点 下添加secure_file_priv='',然后重启mysql服务。linux下 在 /etc/my.cnf中添加secure_file_priv=''。
 
1、我选择前者修改默认的路径
 
[root@seiang mysql]# vim /etc/my.cnf
 
[mysqld]
 
secure_file_priv=''
 
2、重新启动mysql服务
 
[root@seiang mysql]# systemctl restart mysqld.service
 
3、再次查看该变量取值为NULL
 
root@localhost [team]>show variables like '%secure%';
 
ERROR 2006 (HY000): MySQL server has gone away
 
No connection. Trying to reconnect...
 
Connection id:    2
 
Current database: team
 
+--------------------------+-------+
 
| Variable_name        | Value |
 
+--------------------------+-------+
 
| require_secure_transport | OFF  |
 
| secure_auth         | ON   |
 
| secure_file_priv     |    |
 
+--------------------------+-------+
 
3 rows in set (0.13 sec)
 
4、再次执行导出操作,成功
 
root@localhost [team]>select * from team.player into outfile "/tmp/player.txt";
 
Query OK, 3 rows affected (0.00 sec)
 
到此,关于“怎么解决数据库报错ERROR 1290问题”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

dawei

【声明】:站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。