I already have and database in MySQL for my one Django project. I need to make two separate Django projects share the same database.
project1/settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS' : {
'read_default_file': '/etc/mysql/my.cnf',
},
}
}
project1/etc/mysql/my.cnf:
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[client]
database = project1
user = project_user
password = Password
port = 3307
default-character-set = utf8
Here, can I have a different database (database = project2) for my second project?
I am willing to use same user and same password.
How can I do that?
/etc/mysql/my.cnffrom my project2 , it's show same thinks for project1 and project2.database, so after creatuing a new datqabase, inmyssql work bench or with mysql client you edit the my.cnf file of your new proiject one project can also have multiple databases docs.djangoproject.com/en/3.2/topics/db/multi-db