如何在Fedora 37上的Django中配置MariaDB

chhkpiq4  于 2023-06-25  发布在  Go
关注(0)|答案(1)|浏览(128)

我正在创建一个新的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的这个排斥问题?

gmol1639

gmol16391#

  1. MariaDB基本上与MySQL相同,但具有更宽松的许可证。同时安装这两个程序会导致冲突,所以通常不鼓励这样做,除非你对Unix了如指掌。
    1.您的Django设置似乎很好。
    1.检查SELinux是否导致您的问题。一种快速检查的方法是通过执行sudo setenforce 0并检查Django项目是否正常工作(稍后执行sudo setenforce 1将其重新打开,即强制模式)将其转换为许可模式
    1.您可能还需要python3-develmariadb-devel
    1.你试过sudo dnf install mariadb mariadb-server然后sudo systemctl start mariadb然后sudo systemctl enable mariadb

相关问题