Installation of MySQL in Ubuntu

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
  2. 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
  3. 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

  4. Create the new nearbeach user

    CREATE USER 'nearbeach'@'localhost' IDENTIFIED BY '<<password>>';

  5. Create the database NearBeach
    CREATE DATABSE NearBeach;
  6. Grant the nearbeach user access to the NearBeach database

    GRANT ALL PRIVILEGES ON NearBeach.* TO 'nearbeach'@'localhost';

  7. Flush all priveledges
    FLUSH PRIVILEGES;
  8. Exit mysql
    exit
  9. 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',

        }

    }

  10. Restart gunicorn
    sudo service gunicorn restart
  11. Migrate the basic Django admin tables to the database
    source <<virtualenv_location>>/bin/activate
    pip install mysqlclient

    cd <<django_project_location>>
    ./manage.py migrate
  12. Create the super user for the Django Project
    ./manage.py createsuperuser
    Follow the prompts to create the superuser
  13. Test your Django project by visiting your site
    https://<<your_domain_or_IP>>

You should now have a blank page.