Database Setup
The My Marketing Pro application uses MySQL for data storage. This guide covers database setup and synchronization.
Database Overview
Section titled “Database Overview”Production Database (AWS RDS)
Section titled “Production Database (AWS RDS)”- Host:
my-marketing-pro.cluster-c3mws4moov6r.us-east-2.rds.amazonaws.com - Database:
mmp_app - User:
admin - Tables: 405 tables across 23 feature areas
Local Database
Section titled “Local Database”- Host:
localhost - Database:
mmp_app - User:
root - Password: (empty for local development)
Quick Setup
Section titled “Quick Setup”Create Local Database
Section titled “Create Local Database”# Connect to MySQLmysql -u root
# Create databaseCREATE DATABASE mmp_app;
# ExitexitSync Schema from Production
Section titled “Sync Schema from Production”The easiest way to get the database structure locally:
# Export schema from production and import to localmake db-syncThis command:
- Exports the schema (structure only, no data) from production
- Saves it to
/tmp/mmp_app_schema.sql - Imports it into your local
mmp_appdatabase
Manual Database Operations
Section titled “Manual Database Operations”Export Schema Only
Section titled “Export Schema Only”# Export structure without datamake db-exportThis creates /tmp/mmp_app_schema.sql (~11,124 lines) containing:
- Table definitions
- Indexes
- Foreign keys
- Views
Import Schema
Section titled “Import Schema”# Import the schema filemake db-importView Schema File
Section titled “View Schema File”# Check the file sizels -lh /tmp/mmp_app_schema.sql
# Preview the first few lineshead -50 /tmp/mmp_app_schema.sql
# Count lineswc -l /tmp/mmp_app_schema.sqlDatabase Management
Section titled “Database Management”Start/Stop MySQL
Section titled “Start/Stop MySQL”# Start MySQL servicemake db-start
# Stop MySQL servicemake db-stopCheck MySQL Status
Section titled “Check MySQL Status”# View running servicesbrew services list
# Check if MySQL is runningbrew services list | grep mysqlConnect to Database
Section titled “Connect to Database”# Connect to local databasemysql -u root mmp_app
# Common SQL commandsSHOW TABLES; # List all tablesDESCRIBE app_users; # Show table structureSELECT COUNT(*) FROM app_users; # Count recordsConfiguration
Section titled “Configuration”The application automatically detects whether to use local or production database based on the hostname.
Config Files
Section titled “Config Files”Check these files for database configuration:
config.php:15-18- Main database connectionincludes/config.php- Additional configurationincludes/db.php- Database helpers
Local Detection
Section titled “Local Detection”if ($_SERVER['HTTP_HOST'] === 'localhost' || strpos($_SERVER['HTTP_HOST'], 'localhost:') === 0) { $host = 'localhost'; $db = 'mmp_app'; $user = 'root'; $pass = '';}Understanding the Schema
Section titled “Understanding the Schema”Database Size
Section titled “Database Size”- Total Tables: 405
- Schema File: ~11,124 lines
- Main Categories: 23 feature areas
Key Table Groups
Section titled “Key Table Groups”-
User Management (15 tables)
app_users,app_admins,app_auth_tokens
-
Contacts & CRM (35 tables)
app_contacts,app_contact_lists,app_contact_tags
-
Campaigns (65+ tables)
app-campaigns,app_campaign_analytics
-
Messaging (50+ tables)
app_email_campaigns,app_sms_messages
See Database Structure for complete details.
Troubleshooting
Section titled “Troubleshooting””Database does not exist"
Section titled “”Database does not exist"”# Create the databasemysql -u root -e "CREATE DATABASE mmp_app;""Access denied for user”
Section titled “"Access denied for user””For local development, MySQL should allow root access without a password:
# Connect to MySQL as rootmysql -u root
# If that fails, reset the passwordmysql.server stopmysqld_safe --skip-grant-tables &mysql -u rootFLUSH PRIVILEGES;ALTER USER 'root'@'localhost' IDENTIFIED BY '';FLUSH PRIVILEGES;Import Fails with Errors
Section titled “Import Fails with Errors”# Check MySQL versionmysql --version
# Ensure you're using MySQL 8.0+brew upgrade mysqlSchema File Not Found
Section titled “Schema File Not Found”# Re-export from productionmake db-export
# Verify it was createdls -lh /tmp/mmp_app_schema.sqlNext Steps
Section titled “Next Steps”- Database Structure - Understand all 405 tables
- Local Development - Complete setup guide
- Development Workflow - Development best practices