/apollo-mysql-server

Apollo MySQL Server

Primary LanguageSwift

Apollo MySQL Server

Node.js server with Apollo GraphQL and MySQL.

DigitalOcean Droplet Installation

  1. Sign in to your DigitalOcean account.
  2. Select Create -> Droplet for creating a new droplet.
  3. From the Distributions list please select CentOS.
  4. Choose the plan and the datacenter region that meet your requirements.
  5. Also please alter the remaining options regarding your needs.
  6. Click on Create Droplet.

DigitalOcean Firewall Configuration

  1. Select Networking -> Firewalls -> Create Firewall.
  2. Set a name for your new Firewall.
  3. Add a Custom inbound rule with the TCP protocol using the port number 3001.
  4. Add a MySQL inbound rule with the TCP protocol using the port number 3306.
  5. Scroll down to the bottom of the page and apply the Firewall to the recently created droplet.
  6. Click on Create Firewall.

Droplet Setup

  1. Sign in to your droplet via terminal with root user.
  2. Install Node.js using
    yum install -y nodejs
  3. Install MySQL using
    yum install -y mysql-server
  4. Install Git using
    yum install -y git
  5. Clone the following GitHub repo using
    git clone https://github.com/relatedcode/apollo-mysql-server
  6. Enter the cloned repo folder with
    cd apollo-mysql-server

MySQL Configuration

  1. Start the MySQL Service using
    service mysqld start
  2. Configure MySQL using
    mysql_secure_installation
  3. Answer the following questions as described below.
  • Would you like to setup VALIDATE PASSWORD component? - No
  • Please set the password for root here. New password: - Related123
  • Remove anonymous users? - Yes
  • Disallow root login remotely? - No
  • Remove test database and access to it? - Yes
  • Reload privilege tables now? - Yes

MySQL Database and User Configuration

  1. To customize your MySQL database and MySQL user account details make changes in the following files:
  • database/CreateDatabase.sql
  • database/CreateUser.sql
  • .env
  1. Enter MySQL console using
    mysql -u root -p
  2. Enter the MySQL password provided earlier
    Related123
  3. Create the MySQL database using
    SOURCE database/CreateDatabase.sql;
  4. Create the MySQL user account using
    SOURCE database/CreateUser.sql;
  5. Exit MySQL console using
    EXIT;

Apollo Server Installation

  1. Install the predefined packages using
    npm install
  2. Install PM2 using
    npm install pm2 -g
  3. Start the Apollo server with
    pm2 start index.js
  4. You can exit from the droplet using
    exit

Apollo GraphQL admin page

You can check the Apollo GraphQL admin page from your browser entering the server IP address with the port number (like this: http://your-server-ip-address:3001).

Remote Database Access

To connect your Database remotely using a Database Manager application, please use the following values:

  • Host: your-server-ip-address
  • Port: 3306
  • User: remote
  • Password: Related123
  • Database: messenger