我正在创建一个新的Django项目,希望使用mariadb而不是sqlite。我看了几本书,就像这本:https://medium.com/code-zen/django-mariadb-85cc9daeeef8)以及Django文档。据我所知,我需要同时安装mysql和mariadb才能让它工作。我已经用pip3在我的虚拟环境中安装了mysqlclient。然后,我开始了我的django项目,并按照上面的指南中的建议编辑和保存了www.example.com的DATABASE部分settings.py(我选择了自己的项目名称,用户名和密码):
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databasesDATABASES = {
‘default’: {
‘ENGINE’: ‘django.db.backends.mysql’,
‘NAME’: ‘myproject’,
‘USER’:’yourusername’,
‘PASSWORD’:’yourpassword',
‘HOST’:’localhost’,
‘PORT’:’’,
}
}
这就是问题的开始。我按照指南并尝试安装mariadb,然后:sudo dnf install mariadb
但是我得到了一个错误:
Error:
Problem: problem with installed package community-mysql-8.0.32-1.fc37.x86_64
- package community-mysql-8.0.32-1.fc37.x86_64 conflicts with mariadb provided by mariadb-3:10.5.16-3.fc37.x86_64
- package mariadb-3:10.5.16-3.fc37.x86_64 conflicts with community-mysql provided by community-mysql-8.0.32-1.fc37.x86_64
- package community-mysql-8.0.30-2.fc37.x86_64 conflicts with mariadb provided by mariadb-3:10.5.16-3.fc37.x86_64
- package mariadb-3:10.5.16-3.fc37.x86_64 conflicts with community-mysql provided by community-mysql-8.0.30-2.fc37.x86_64
- conflicting requests
- package community-mysql-8.0.32-1.fc37.x86_64 conflicts with mariadb provided by mariadb-3:10.5.18-1.fc37.x86_64
- package mariadb-3:10.5.18-1.fc37.x86_64 conflicts with community-mysql provided by community-mysql-8.0.32-1.fc37.x86_64
- package community-mysql-8.0.30-2.fc37.x86_64 conflicts with mariadb provided by mariadb-3:10.5.18-1.fc37.x86_64
- package mariadb-3:10.5.18-1.fc37.x86_64 conflicts with community-mysql provided by community-mysql-8.0.30-2.fc37.x86_64
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages)
我做了一些研究,看起来在Fedora中,mysql和mariadb互相排斥。我没能找到解决这个问题的办法。首先,在Django项目中添加mariadb代替sqlite是正确的方法吗?如果是这样,我该如何解决Fedora的这个排斥问题?
1条答案
按热度按时间gmol16391#
1.您的Django设置似乎很好。
1.检查SELinux是否导致您的问题。一种快速检查的方法是通过执行
sudo setenforce 0
并检查Django项目是否正常工作(稍后执行sudo setenforce 1
将其重新打开,即强制模式)将其转换为许可模式1.您可能还需要
python3-devel
和mariadb-devel
1.你试过
sudo dnf install mariadb mariadb-server
然后sudo systemctl start mariadb
然后sudo systemctl enable mariadb
吗