Skip to content

Latest commit

 

History

History
50 lines (46 loc) · 3.42 KB

RDS.md

File metadata and controls

50 lines (46 loc) · 3.42 KB

RDS is one of Amazon services that can be used to create database.

RDS

To create database and connect it to your code. You should follow the steps bellow:

  1. Open your AWS management cosole.
  2. In All Services option you will find Database.Click on RDS.
  3. Click on create database

screen shot 2018-10-18 at 11 03 32 am

screen shot 2018-10-18 at 11 05 33 am

4. Choose type of the database (I chose mysql)

screen shot 2018-10-18 at 11 06 49 am

5. Enter database Instance name and username and password. You need these with database connection in your code.

screen shot 2018-10-18 at 11 12 17 am

6. database name and port. You also need these with database connection in your code.

screen shot 2018-10-18 at 11 12 29 am

7.Click on create database

screen shot 2018-10-18 at 11 13 03 am

8. Back to Dashboard and click on DB Instances

screen shot 2018-10-18 at 11 15 22 am

9. Click on database and click on DB Instance that you create.

screen shot 2018-10-18 at 11 15 38 am

10. Now you can get endpoint and DB name and username.

screen shot 2018-10-18 at 11 15 58 am

11. Go to application.py and change the following based on your database.
```
    app.config['MYSQL_DATABASE_HOST'] = 'endpoint of the database from RDS'
    app.config['MYSQL_DATABASE_USER'] = 'username of the database from RDS'
    app.config['MYSQL_DATABASE_PASSWORD'] = 'Password of the database from RDS'
    app.config['MYSQL_DATABASE_DB'] = 'name of the of the database from RDS'
  ```
  1. Go to terminal and enter the followings:
      export PATH=$PATH:/usr/local/mysql/bin
      mysql -h <endpoint> -P 3306 -u <username> -p
    
  2. Click eneter Then termianl will ask you to enter password. Enter your DB password.
  3. Enter your mysql code (e.g. create tabel)

screen shot 2018-10-18 at 11 38 04 am

15. The following mysql code is to create table that will work in my example above.
 ```
      show databases;
      use yourdatabase name;
      CREATE TABLE users( 
      id INTEGER PRIMARY KEY AUTO_INCREMENT, 
      name varchar(20) UNIQUE NOT NULL,email varchar(30), 
      password TEXT NOT NULL);
      
  ```