Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
Django + MySQL Setup (Using Docker)
This project sets up a Django application connected to a MySQL database using Docker. No local MySQL installation is required.

Quick Start
1. Run MySQL via Docker
Use the following command in your terminal:

docker run --name mysql
-e MYSQL_ROOT_PASSWORD=password123
-e MYSQL_DATABASE=elderco
-p 3307:3306
-d mysql:8

What this does:

Starts a MySQL container named mysql

Sets root password to password123

Creates a database named elderco

Exposes container’s port 3306 on host’s port 3307

2. Install Python Dependencies
Make sure you have a virtual environment activated, then run:

pip install mysql-connector-python

3. Configure Django Database Settings
In your Django settings.py file, set the following:

DATABASES = {
'default': {
'ENGINE': 'mysql.connector.django',
'NAME': 'elderco',
'USER': 'root',
'PASSWORD': 'password123',
'HOST': '127.0.0.1',
'PORT': '3307',
}
}

4. Apply Migrations and Start Django
Run the following commands:

python manage.py migrate
python manage.py runserver

Then visit http://127.0.0.1:8000 in your browser.

Optional: Access MySQL CLI in Container
To access the database shell:

docker exec -it mysql mysql -u root -p

Then enter the password password123. You can use SQL commands like:

SHOW DATABASES;
USE elderco;

Stop and Remove the MySQL Container
To stop and clean up the container:

docker stop mysql
docker rm mysql

Project Structure
your_project/
├── dcrm/
│ └── settings.py
├── website/
├── manage.py
└── README.md

Requirements:

Python 3.x

pip

Docker