我正在使用 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/