Installation of MySQL ServerΒΆ
The following quick instructions will inform you on how to install MySQL in Ubuntu for NearBeach. This will also cover the generation of the NearBeach user for the database
- Install the following packages
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
- Once installation of the mysql-server has been completed, setup your root user
sudo mysql_secure_installation
- Follow the prompts with creating a root user, we had the following answers
- Once mysql has been completely, log into mysql to install the NearBeach user
sudo mysql -u root -penter in the root password for MySQL
- Create the new nearbeach user
CREATE USER 'nearbeach'@'localhost' IDENTIFIED BY '<<password>>';Create the database NearBeach
CREATE DATABASE NearBeach;Grant the nearbeach user access to the NearBeach database
GRANT ALL PRIVILEGES ON NearBeach.* TO 'nearbeach'@'localhost';Flush all priveledges
FLUSH PRIVILEGES;Exit mysql
exit
- Edit the django project settings file to allow your django project access to the mysql database
cd <<django_project_location>> nano ./<<django_project>>/settings.py
- Add the following code into the database section of the settings file
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': '<<mysql database>>', 'USER': '<<mysql username>>', 'PASSWORD': '<<mysql password>>', 'HOST': 'localhost', # Or an IP Address that your DB is hosted on 'PORT': '3306', } }
- Restart gunicorn
sudo service gunicorn restart
- Migrate the basic Django admin tables to the database
source <<virtualenv_location>>/bin/activate pip install mysqlclient cd <<django_project_location>> ./manage.py migrate
- Create the super user for the Django Project
./manage.py createsuperuser
Follow the prompts to create the superuser
- Test your Django project by visiting your site
https://<<your_domain_or_IP>>
You should now have a blank page.