mysql shell 脚本中出现意外的 EOF [英] Unexpected EOF in mysql shell script

查看:71
本文介绍了mysql shell 脚本中出现意外的 EOF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 shell 中获取了一些 mysql 信息,如下所示:

I'm getting some mysql info from shell like this:

#!/bin/bash
keyOrPass=$1
intercom=$2
flat=$3
number=$4
mysql -ulogin -ppassword db_name << EOF
select codeGuestEmail, codePrivateEmail from mbus_clients WHERE flat=$flat and domophone=$intercom;
EOF

我在一些教程中找到了这个解决方案,但它说:检查与您的 MySQL 服务器版本相对应的手册,了解在EOF"附近使用的正确语法怎么了?我怎样才能完成mysql会话?http://www.cyberciti.biz/faq/using-mysql-in-shell-scripts/ 这里是我找到解决方案的教程示例.
UPDATE 向 EOF 添加不同的引号也不起作用.

I found this solution in some tutorial, but it says: check the manual that corresponds to your MySQL server version for the right syntax to use near 'EOF' What's wrong? How can I finish mysql session? http://www.cyberciti.biz/faq/using-mysql-in-shell-scripts/ here is example of tutorial where I found solution.
UPDATE added different quotes to EOF doesn't work too.

推荐答案

在您的查询中传递带引号的动态变量 ..

in your query pass the dynamic variable with quotes ..

select codeGuestEmail, codePrivateEmail from mbus_clients WHERE flat='$flat' and domophone='$intercom';

或者试试这个

select codeGuestEmail, codePrivateEmail from mbus_clients WHERE flat=${flat} and domophone=${intercom};

这篇关于mysql shell 脚本中出现意外的 EOF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆