Cod*_*e K 3 postgresql windows command-line ddl postgresql-10
我使用以下批处理文件在 PostgreSQL 10 中创建一个新数据库。
echo off
cd "C:\Program Files (x86)\PostgreSQL\10\bin"
createdb -h localhost -p 5432 -U postgres myDB
Run Code Online (Sandbox Code Playgroud)
但它要求输入密码。如何防止要求输入密码?我尝试使用此链接中-w解释的选项不要求输入密码提示。但这不起作用。如何防止要求密码?
使用PGPASSWORD环境变量,
@SET PGPASSWORD=something_secret
psql -c "CREATE DATABASE mydb" -U postgres postgres
Run Code Online (Sandbox Code Playgroud)
或者只使用连接字符串
psql -c "CREATE DATABASE mydb" "user=postgres dbname=postgres password=something_secret"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5462 次 |
| 最近记录: |