【问题标题】:mysql script in shell using variables在shell中使用变量的mysql脚本
【发布时间】:2021-03-15 12:59:03
【问题描述】:

我想在带有变量的 shell 脚本中使用 mysql 语法, 我用错了什么?

#!/bin/bash

mysql <MyBlaBlaDB> -e "select * from table where something = &1"

我正在尝试将其作为 ./test.sh 运行

【问题讨论】:

  • 我在您的代码中没有看到任何变量用法。

标签: mysql shell


【解决方案1】:

试试这个方法

#!/bin/bash

something="anyting"
mysql -u [username] -p[password] [datbase name] -e "select * from table where something = $something"

【讨论】:

    猜你喜欢
    • 2023-03-20
    • 2011-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-20
    • 2022-01-18
    相关资源
    最近更新 更多