Step 1: Install MYSQL database, MYSQL workbench and some prerequisites to connect django to the database using the following commandsudo apt install mysql-server libmysqlclient-dev python-dev mysql-workbench
orsudo apt-get install mysql-server libmysqlclient-dev python-dev mysql-workbench
Enter the root password and confirm it when prompted
The first command is for older Linux while the second is for a newer version of Linux
Step 2: Navigate into the virtual environment, Activate the virtual environment and install mysql-python using the followingcd venv
(where venv is the name of the virtual environment)source bin/activate
pip install mysql-python
pip install mysqlclient
Step 3: Open mysql workbench, create a database (schema) and username to be used to connect to the database.
database name = compinventory
Username = youtube
Password = myPassword
Step 4: In the application settings.py file, configure django to use MYSQL Database instead of the sqlite file.
in this example we are using the database and username and created in the above step:
database name = compinventory
Username = youtube
Password = myPassword
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'compinventory',
'USER': 'youtube',
'PASSWORD': 'myPassword',
}
}
Step 5: Do migrate for Django to create the application tables to the newly configured database. ./manage.py migrate
./manage.py runserver