mysql 命令行输出到文件_命令行MySQL查询将输出导出到文件在Windows中不起作用

bd96500e110b49cbb3cd949968f18be7.png

Version of mysql is mysql Ver 14.14 Distrib 5.5.53, for Win64 (AMD64)

After running below commands, the output still goes to stdout

mysql -uroot -proot DBinstance

select * from tablename\G INTO OUTFILE 'c:\users\12345\Downloads\some_non_existingfile'

What is the problem with above command?

Edit:

I get below error after re-correcting the select query:

ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv opti

on so it cannot execute this statement

mysql> SHOW VARIABLES LIKE "secure_file_priv";

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

| Variable_name | Value |

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

| secure_file_priv | NULL |

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

1 row in set (0.00 sec)

Currently G:\..\mysql> dir have folders bin, data, lib, scripts & tmp.

解决方案

remove the \G flag.

select * from tablename INTO OUTFILE 'c:\users\12345\Downloads\some_non_existingfile'

you also need to make sure that

The MySQL server is not running with the --secure-file-priv option

to allow for writing output to a folder

add or amend your mysql config file (my.ini) by adding/amending the following line.

secure-file-priv = ""

or

secure-file-priv = "FOLDER-PATH-OF-YOUR-CHOICE"

then restart the mysql server using

net stop mysql

net start mysql

little info about the setting

If empty, the variable has no effect.

If set to the name of a directory, the server limits import and export operations to work only with files in that directory. The directory must exist; the server will not create it.

If set to NULL, the server disables import and export operations. This value is permitted as of MySQL 5.7.6.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值