【问题标题】:How can I execute the creation of user for psql using a bash?如何使用 bash 为 psql 创建用户?
【发布时间】:2022-01-11 03:37:06
【问题描述】:

我正在尝试这样做:

sudo -H -u postgres bash -c 'psql -c "CREATE USER admin WITH PASSWORD "qwerty";"'

我将它放在一个文件中并执行,但它不起作用......

我想是因为引号和双引号...

如何使用 bash 文件为 psql 创建用户?

非常感谢!

【问题讨论】:

    标签: postgresql bash psql


    【解决方案1】:

    SQL 中的字符串需要单引号。你可以使用

    sudo -H -u postgres psql -c "CREATE USER admin WITH PASSWORD 'qwerty'"
    

    【讨论】:

      猜你喜欢
      • 2022-01-10
      • 2021-08-07
      • 1970-01-01
      • 2020-07-21
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 2018-04-05
      • 1970-01-01
      相关资源
      最近更新 更多