当我尝试使用命令行测试任何应用程序时(我注意到这一点是在尝试使用使用此命令的Fabric部署我的项目时),会出现以下情况:
python manage.py test appname
我遇到了这个错误:
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_finance', or 'no' to cancel
syncdb
命令似乎有效。我的 settings.py 文件中的数据库设置为:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'finance', # Or path to database file if using sqlite3.
'USER': 'django', # Not used with sqlite3.
'PASSWORD': 'mydb123', # Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
GRANT ALL PRIVILEGES ON test_my_db.* TO 'my_user'@'localhost';
- Yacine Rouizi