Today we will learn how to set up the Mysql database in our shared hosting Cpanel. I am using them here Namecheap you can use any of them. There are several steps you have to follow. Read them carefully and follow them you can easily do that.
First of all, go to the terminal with your project-specific virtualenv . See how to set up virtualenv in the Django project for Cpanel hosting here and follow the Mysql database setup. Then in the next steps install this package specify here.
##)Create New Database
##)Give Database Name
Here you need to put your database name and click Create Database
##)MySQL Users Add New User
fillup the MySQL Users Add New User form and click Create User
##)Add User To Database
After that, you need to checkmark the correct username and database name you just created in the previous step and hit Add.
##)Manage User Privileges
Then checkmark ALL PRIVILEGES and click make the change.
1. Mysql database installation
pip install pymysql
2. After that we need to install mysqlclient
pip install mysqlclient
There is a valid reason that your installation will get an error. unable to execute '/usr/bin/gcc':Permission denied.Follow this to slove that. After that follow our tutorial again
**Mysql database client installation keep in mind that the latest version of mysqlclient will not work properly. After lots of investigation I
found mysqlclient==2.1.0 is working properly.So install mysqlclient==2.1.0 .
pip install mysqlclient==2.1.0
3. After that we need to configure our database setup in our setting.py file. Just copy this below code and change the database name to your created database name the database username to your previously created username and change the password to your own database password. Keep host, port and engine as it is.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'database name ',
'USER': 'database username ',
'PASSWORD': 'database password',
'HOST': 'localhost',
'PORT': '3306',
}
}
5. After completion of the previous steps your setup is complete you are good for the final steps.
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
And that's it you are ready to go with this setup. Your database connection is ready you can work with it.
Learn How to deploy django application in shared hosting
Learn How to solve: unable to execute '/usr/bin/gcc':Permission denied in Namecheap
Learn How to develop a full stack development project from planning to coding
There is no comment yet!