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

  1. Install the following packages

sudo apt-get install mysql-server mysql-client libmysqlclient-dev
  1. Once installation of the mysql-server has been completed, setup your root user

sudo mysql_secure_installation
  1. Follow the prompts with creating a root user, we had the following answers

  2. Once mysql has been completely, log into mysql to install the NearBeach user

sudo mysql -u root -p

enter in the root password for MySQL

  1. 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
  1. 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
  1. 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',
    }
}
  1. Restart gunicorn

sudo service gunicorn restart
  1. Migrate the basic Django admin tables to the database

source <<virtualenv_location>>/bin/activate
pip install mysqlclient
cd <<django_project_location>>
./manage.py migrate
  1. Create the super user for the Django Project

./manage.py createsuperuser

Follow the prompts to create the superuser

  1. Test your Django project by visiting your site

https://<<your_domain_or_IP>>

You should now have a blank page.