mysql - 从 bash 输出 sql 输出

标签 mysql bash

我正在使用 OUTFILE 命令,但由于权限问题和安全风险,我考虑将 shell 的输出转储到文件,但出现了一些错误。 我尝试过的事情

#This is a simple shell to connect to mysql db
cat  mysql -h "localhost" -u  "XXXXXXX" "-pXXXXXX"  standard_new2 << EOF
select * from cnhdatad limit 10;
EOF  ./sample2.txt

最佳答案

这对于 Heredoc 来说是不正确的输出重定向语法。

尝试这个命令:

mysql -h "localhost" -u  "XXXXXXX" "-pXXXXXX"  standard_new2 << EOF > ./sample2.txt
select * from cnhdatad limit 10;
EOF

关于mysql - 从 bash 输出 sql 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19726130/

相关文章:

MySql 自动增量 id 中的间隙

arrays - Bash - 指向关联数组中值的指针?

bash - 使用awk计算时间差

json - JQ - 如何从键中删除引号

MySQL ALL 运算符的问题

php - 清理和验证 php 表单

bash - 期待函数 bash

bash - Bash 中的定时器事件

MySQL 查询错误 IF、END IF

MYSQL REGEXP 查询关键字列