Lesson 1: Heroku Database and MySQL Workbench Connections
Learn to set up cloud databases with JawsDB MySQL on Heroku and connect using MySQL Workbench for visual database management.
Lesson Objectives
- Set up new projects using the CRUD F25 starter template
- Create GitHub repositories and connect to Heroku for auto-deployment
- Add and configure JawsDB MySQL add-on in Heroku applications
- Install MySQL Workbench and connect to cloud databases
- Navigate MySQL Workbench interface for database management and testing
Watch: Heroku Database and MySQL Workbench Connections Tutorial
Heroku Database and MySQL Workbench Connections - Notes
Complete Project Setup Workflow
1. Start with CRUD F25 Template:
- Use the starter template "CRUD F25" for the rest of the semester
- Template repository: https://github.com/bamarshall06/starter-template-crud-f25
- This is our new foundational template moving forward
2. Create GitHub Repository:
- Create new repository from CRUD F25 template
- Name it "Mars Demo 3" (following video example)
- Make repository private
- Create the repository
3. Create Heroku Application:
- Go to Heroku and create new app
- Name it "Mars demo 3" (matching GitHub repo)
- Create the app
- Immediately connect to GitHub repository
- Enable automatic deploys from main branch
- Deploy branch to get initial deployment
Local Development Environment Setup
Virtual Environment Commands:
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
python app.pyVerify local setup:
- Test application at http://127.0.0.1:5000
- Confirm starter kit is working properly
JawsDB MySQL Database Setup
Add JawsDB Add-on to Heroku:
- Go to Heroku app → Resources tab
- Create new database by searching for "MySQL"
- Select "JawsDB" from the search results
- Choose the free version
- Click "Submit Order" to provision the database
Get Database Connection Credentials:
- Click on the JawsDB add-on to view connection details
- Copy all credentials (hostname, username, password, database name)
- Paste credentials into notepad document for temporary reference
- Note: These credentials will be deleted after the lesson for security
MySQL Workbench Installation & Configuration
Download and Install:
- Search for "MySQL workbench download" in browser
- Download and install MySQL Workbench (free from Oracle)
- Launch the application after installation
Create New Connection:
- Click to create a new connection
- Name the connection (e.g., "Mars demo3")
- Enter hostname from JawsDB credentials (be careful of spaces)
- Enter username from JawsDB credentials
- Store password in vault (click "Store in Vault")
- Change default schema to your database name
- Test connection to verify setup
- Click "OK" if test is successful
Environment Variables and Security
Local .env File Setup:
DB_HOST=your_hostname
DB_USER=your_username
DB_PASSWORD=your_password
DB_NAME=your_database_nameHeroku Config Variables:
- Go to Heroku → Settings → Config Vars
- Add each database credential as separate config variable
- Use exact same variable names as in .env file
- This provides secure way to pass database credentials
Important Security Notes:
- .env files are never pushed to GitHub (in .gitignore)
- Heroku config vars are the secure production method
- Always double-check for extra spaces when copying credentials