【MySQL报错】ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it ca

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

mysql 默认对导出的目录有权限限制,也就是说使用命令行进行导出的时候,须要指定目录进行操做;mysql

解决方法:

方法一:sql

  使用语句查询secure_file_priv 的值:show global variables like '%secure%';this

方法二:spa

  使用 into outfile 开始导出:(由于secure_file_priv配置的关系,因此必须导出到  /var/lib/mysql-files/目录下)命令行

select * from table_name where a = 'test'
into outfile '/var/lib/mysql-files/test.txt'  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';

PS:FIELDS TERMINATED BY  ','  OPTIONALLY ENCLOSED BY  ' " '  LINES TERMINATED BY '\n';由于导出的数据会出现一些乱码或者特殊字符,因此使用以上关键字进行转义code

相关文章
相关标签/搜索