我创建数据库时致命

时间:2015-01-13 09:05:35

标签: django database postgresql digital-ocean

我想使用Fabric自动安装postgres数据库。 为此,请阅读本教程:https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn

我写了代码:

def fresh_database():
     "" "
     install database
     "" "
     local ('pip install -r Requirements/prod.txt')
     local ('sudo apt-get install python-dev libpq-dev')
     local ('sudo apt-get install postgresql postgresql-contrib)
     local ('sudo su - postgres')
     local ('createdb mydb')
     local ('createuser -P')

     print (green ('OK.'))

但是当我创建数据库时,我收到错误:createdb:无法连接到数据库postgres:致命:用户密码验证失败" postgres"

1 个答案:

答案 0 :(得分:0)

您可以尝试:

sudo('psql -U postgres -c "CREATE DATABASE mydb WITH OWNER username")

它应该有用。