django – Travis:“创建测试数据库时出错:创建数据库的权限被拒绝”
发布时间:2020-12-15 13:55:50 所属栏目:Python 来源:互联网
导读:这是我的travis.yml文件: language: pythonpython: - 2.7addons: postgresql: 9.3env: - SECRET_KEY=test DB_NAME=dbtest DB_USER=test DB_PASS=testbefore_install: - export DJANGO_SETTINGS_MODULE=set
|
这是我的travis.yml文件: language: python python: - "2.7" addons: postgresql: "9.3" env: - SECRET_KEY=test DB_NAME=dbtest DB_USER=test DB_PASS=test before_install: - export DJANGO_SETTINGS_MODULE=settings.local - export PYTHONPATH=$HOME/builds/me/myrepo install: - pip install -r requirements.txt before_script: - psql -U postgres -c 'CREATE DATABASE dbtest;' - psql -U postgres -c "CREATE EXTENSION postgis" -d dbtest - psql -U postgres -c "CREATE EXTENSION postgis_topology" -d dbtest - psql -U postgres -c "CREATE USER test WITH PASSWORD 'test';" - psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE dbtest to test;" - cd myapp && python manage.py migrate script: - python manage.py test 但是当我部署repo并运行Travis时,它会输出以下错误: 10.96s$pip install -r requirements.txt 0.24s$psql -U postgres -c 'CREATE DATABASE dbtest;' 0.77s$psql -U postgres -c "CREATE EXTENSION postgis" -d dbtest 0.09s$psql -U postgres -c "CREATE EXTENSION postgis_topology" -d dbtest 0.01s$psql -U postgres -c "CREATE USER test WITH PASSWORD 'test';" 0.01s$psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE dbtest to test;" 1.89s$cd myapp && python manage.py migrate $python manage.py test Creating test database for alias 'default'... Got an error creating the test database: permission denied to create database Type 'yes' if you would like to try deleting the test database 'test_dbtest',or 'no' to cancel: 我尝试添加psql -U postgres -c“ALTER USER django CREATEDB;”这样django用户就有权创建数据库,但失败了: ERROR: role "django" does not exist The command "psql -U postgres -c "ALTER USER django CREATEDB;"" failed and exited with 1 during . 解决方法答案:我必须让测试用户成为超级用户:CREATE USER test WITH PASSWORD 'test'; 然后授予用户创建数据库的权限: ALTER USER test CREATEDB; (编辑:南阳站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 使用Python将二进制数据写入套接字(或文件)
- python – 使用Tensorflow中的多层感知器模型预测文本标签
- Python:Tkinter小部件背景(按钮,条目等)
- python – 为什么pow(x,y)的时间复杂度为O(1),而x ** y为O(
- 从python安装脚本中的编译标志中删除ppc
- 使用Python在OpenOffice / Microsoft Word中格式化输出
- 想在Jupyter Notebook(Anaconda)中保存并运行Python脚本
- python – pelican模板中当前页面的URL的变量
- python – Sublime Text 3 API:从文件获取所有文本
- 在python列表解析中解包元组(未使用* -operator)
