使用包含美元符号和感叹号的密码连接到数据库
connection to database with password containing dollar signs and exclamation marks
我正在尝试使用 psql
打开与数据库的连接。
连接字符串如下所示
psql -A -t -c "sql query" postgresql://@/
我作为第一个参数传递的地方
= login:password
= localhost:5432
= dbname
当登录名和密码非常标准(如 123 等)时,它工作正常。
但是当我尝试使用 123412@15!12$
之类的密码进行连接时,它因密码不正确而失败。
如何转义属性?
我会使用更安全的变量放置:
psql -A -t -c "sql query" "postgresql://@/"
此外,参数 $1、$2、$3 应传递为:
script.sh 'login:password' 'localhost:5432' 'dbname'
我正在尝试使用 psql
打开与数据库的连接。
连接字符串如下所示
psql -A -t -c "sql query" postgresql://@/
我作为第一个参数传递的地方
= login:password
= localhost:5432
= dbname
当登录名和密码非常标准(如 123 等)时,它工作正常。
但是当我尝试使用 123412@15!12$
之类的密码进行连接时,它因密码不正确而失败。
如何转义属性?
我会使用更安全的变量放置:
psql -A -t -c "sql query" "postgresql://@/"
此外,参数 $1、$2、$3 应传递为:
script.sh 'login:password' 'localhost:5432' 'dbname'