Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql 使用FreeBSD和Vagrant在Postgres 9.5上创建用户_Postgresql_Vagrant_Freebsd - Fatal编程技术网

Postgresql 使用FreeBSD和Vagrant在Postgres 9.5上创建用户

Postgresql 使用FreeBSD和Vagrant在Postgres 9.5上创建用户,postgresql,vagrant,freebsd,Postgresql,Vagrant,Freebsd,我正在尝试在FreeBSD 11上的Postgresql 9.5中创建一个用户。我还试图用Vagrant自动化整个过程,除了创建用户之外,我几乎成功了。我正在使用带有密码的createuser命令,因此,我尝试使用expect命令将密码发送到提示符,但我继续收到以下错误消息: 默认值:createdb:无法连接到数据库模板1:致命:角色“根”不存在 以下是我正在使用的代码示例: # Create the database and the user PASS=password expect <

我正在尝试在FreeBSD 11上的Postgresql 9.5中创建一个用户。我还试图用Vagrant自动化整个过程,除了创建用户之外,我几乎成功了。我正在使用带有密码的createuser命令,因此,我尝试使用expect命令将密码发送到提示符,但我继续收到以下错误消息:

默认值:createdb:无法连接到数据库模板1:致命:角色“根”不存在

以下是我正在使用的代码示例:

# Create the database and the user
PASS=password
expect << EOF

spawn createuser -sdrP capstone
expect "Enter password for new role:"
send "${PASS}\r"

expect "Enter it again:"
send "${PASS}\r"

expect eof;
EOF
#创建数据库和用户
PASS=密码

expect不要以root用户身份运行此脚本。 默认情况下,用户“pgsql”具有权限。 切换到用户:

su -l pgsql
然后运行expect脚本