MySQL Cloud Database Integration Guide: Complete Tutorial for Migrating from Local to Cloud

MySQL Cloud Database Integration Guide: Complete Tutorial for Migrating from Local to Cloud
Is your MySQL database still running on that old server in the company's server room? Hard drives filling up, performance getting slower, worrying about crashes in the middle of the night. Moving to the cloud can solve most of these problems.
This article will teach you step by step how to migrate MySQL to the cloud. From choosing a platform, planning the migration, actual operations, to post-launch optimization—every step is explained in detail. Whether you're new to cloud or want to confirm you're doing it right, this guide will help.
Further reading: Cloud Database Complete Guide | Understanding cloud database basics
Why Move MySQL to the Cloud?
Advantages of Cloud MySQL
Moving MySQL to the cloud gives you these benefits:
1. No More Managing Hardware Hard drive failures, memory shortages, CPU bottlenecks—all handled by the cloud provider. You just focus on using and optimizing the database.
2. Elastic Scaling Traffic surge? A few clicks to upgrade specs. Promotion over? Scale back down. No need to plan purchases months in advance.
3. Automatic Backup and Disaster Recovery Cloud services have automatic backup by default, and you can set up cross-region replication. Even if an entire data center goes down, your data is safe.
4. High Availability Multi-AZ deployment, automatic failover—features that cost a fortune to build traditionally come with just a checkbox in the cloud.
5. Save Labor Costs No need for dedicated DBAs on 24/7 watch. The cloud provider's team handles the underlying operations.
When to Consider Migration
These situations are especially suitable for migration:
- Hardware expiring soon: Instead of buying new servers, go directly to cloud
- Rapid business growth: Need more flexible scaling capability
- Planning digital transformation: Other systems also moving to cloud, migrate database together
- Insufficient operations staff: No dedicated DBA, want to reduce operations burden
- Need high availability: Business cannot tolerate long downtime
Pre-Migration Assessment Points
Migration isn't something you just do—evaluate these issues first:
1. How Much Data?
- Tens of GB: Migration relatively simple, short downtime
- Hundreds of GB: Needs planning, may take hours
- TB level: Needs professional planning, consider continuous replication
2. How Much Downtime is Acceptable?
- Can tolerate hours: mysqldump is simplest
- Only minutes: Need replication solution
- Zero downtime: Need more complex architecture
3. Does the Application Need Changes?
- Connection string must change
- If using MySQL-specific features, confirm cloud version supports them
- Stored procedures and triggers need testing
4. Is Budget Sufficient?
- Monthly cloud costs vs current hardware depreciation + labor costs
- Don't forget network transfer fees
Three Major Platform MySQL Service Comparison
All three major cloud platforms have MySQL managed services. Detailed comparison: AWS, GCP, Azure Database Complete Comparison
AWS RDS for MySQL
AWS's MySQL service is the most mature with the most options.
| Item | Details |
|---|---|
| MySQL Versions | 5.7, 8.0 |
| Maximum Storage | 64 TB |
| Maximum Connections | 16,000 (depends on specs) |
| Read Replicas | Up to 15 |
| Multi-AZ | ✅ |
| Automatic Backup | Up to 35 days |
Pros:
- Most instance type choices
- Performance Insights analytics is powerful
- Aurora MySQL version has better performance
Cons:
- Relatively higher pricing
- Many configuration options, beginners can get lost
Suitable for: Enterprises already using AWS, scenarios needing maximum flexibility
GCP Cloud SQL for MySQL
Google Cloud's MySQL service is simple and easy to use. Detailed tutorial: Google Cloud Database Complete Tutorial
| Item | Details |
|---|---|
| MySQL Versions | 5.7, 8.0 |
| Maximum Storage | 64 TB |
| Maximum Connections | 4,000 (depends on specs) |
| Read Replicas | Up to 10 |
| High Availability | ✅ |
| Automatic Backup | Up to 365 days |
Pros:
- Clean interface, easy to get started
- Longest backup retention (365 days)
- Has Taiwan data center
Cons:
- Lower connection limit
- Fewer advanced features than AWS
Suitable for: Startups, enterprises needing Taiwan data residency
Azure Database for MySQL
Microsoft Azure's MySQL service, enterprise-oriented.
| Item | Details |
|---|---|
| MySQL Versions | 5.7, 8.0 |
| Maximum Storage | 16 TB |
| Maximum Connections | 5,000 (depends on specs) |
| Read Replicas | Up to 10 |
| High Availability | ✅ |
| Automatic Backup | Up to 35 days |
Pros:
- Good integration with Azure services
- Flexible Server option offers great flexibility
- Has Taiwan data center
Cons:
- Smaller storage limit (16 TB)
- Fewer community resources than AWS
Suitable for: Microsoft ecosystem enterprises, organizations with EA contracts
Feature and Pricing Comparison Table
| Comparison Item | AWS RDS | GCP Cloud SQL | Azure MySQL |
|---|---|---|---|
| Minimum Monthly Cost (est.) | ~$15 | ~$10 | ~$12 |
| Free Tier | 750 hours/month (12 months) | None ($300 trial credits) | 750 hours (12 months) |
| Taiwan Data Center | ❌ | ✅ | ✅ |
| Serverless Option | Aurora Serverless | In Preview | Flexible Server |
MySQL Cloud Migration Steps
Time to actually migrate. Using GCP Cloud SQL as an example—other platforms have similar flows.
Step 1: Assess Your Current Database
Understand your current situation before migrating:
# Check database size
SELECT
table_schema AS 'Database',
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS 'Size (MB)'
FROM information_schema.tables
GROUP BY table_schema;
# Check MySQL version
SELECT VERSION();
# Check character set settings
SHOW VARIABLES LIKE 'character_set%';
SHOW VARIABLES LIKE 'collation%';
# Check current connections
SHOW STATUS LIKE 'Max_used_connections';
Record this information:
- Total database size
- MySQL version
- Character set (charset) and collation
- Maximum concurrent connections
- Engines used (InnoDB, MyISAM)
Step 2: Choose Target Platform and Specs
Based on your assessment:
Choose Platform: Based on which cloud your company uses, budget, whether Taiwan data center is needed
Choose Specs:
- vCPU: Slightly larger than current server, leave some headroom
- Memory: At least the same as now, preferably more
- Storage: Current data x 2, leave room for growth
- Storage Type: Choose SSD, performance is much better
Choose Region:
- Region close to users (Taiwan users choose asia-east1)
- Consider if high availability (Multi-AZ) is needed
Step 3: Create Cloud MySQL Instance
Using GCP Cloud SQL as example:
-
Log into GCP Console
- Go to console.cloud.google.com
- Select or create a project
-
Create Cloud SQL Instance
- Search for "Cloud SQL"
- Click "Create Instance"
- Select "MySQL"
-
Configure Instance
Instance ID: my-mysql-instance (custom) Password: Set root password MySQL Version: Select same version as source Region: asia-east1 (Taiwan) Zone: Single or multiple (high availability) -
Configure Machine Specs
vCPU: Select based on needs Memory: Select based on needs Storage Type: SSD Storage Capacity: Set based on needs Enable automatic storage increases: Recommended -
Configure Connectivity
Public IP: As needed (recommend Private IP) Authorized Networks: Add your IP -
Click "Create" and wait a few minutes
Step 4: Data Migration Methods
Several ways to migrate data:
Method 1: mysqldump (for small databases)
Simplest and most direct, suitable for databases under tens of GB.
# Export from source server
mysqldump -u root -p \
--single-transaction \
--routines \
--triggers \
--databases your_database > backup.sql
# Import to cloud MySQL
mysql -h [CLOUD_SQL_IP] -u root -p your_database < backup.sql
Method 2: Database Migration Service (for large databases)
All three platforms have migration services:
- AWS: Database Migration Service (DMS)
- GCP: Database Migration Service
- Azure: Azure Database Migration Service
These services support continuous replication to minimize downtime.
Method 3: MySQL Replication (for zero downtime requirements)
Set up master-slave replication with cloud MySQL as a replica of your existing database:
-- Configure on source server
GRANT REPLICATION SLAVE ON *.* TO 'repl_user'@'%' IDENTIFIED BY 'password';
-- Configure on cloud MySQL
CHANGE MASTER TO
MASTER_HOST='source_ip',
MASTER_USER='repl_user',
MASTER_PASSWORD='password',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=123;
START SLAVE;
After synchronization, switch application connections and stop replication.
Step 5: Application Connection Setup
After data migration, update application connection settings:
Connection String Examples:
# Python (mysql-connector-python)
import mysql.connector
conn = mysql.connector.connect(
host="[CLOUD_SQL_IP]",
user="your_user",
password="your_password",
database="your_database",
ssl_ca="server-ca.pem",
ssl_cert="client-cert.pem",
ssl_key="client-key.pem"
)
// Node.js (mysql2)
const mysql = require('mysql2');
const connection = mysql.createConnection({
host: '[CLOUD_SQL_IP]',
user: 'your_user',
password: 'your_password',
database: 'your_database',
ssl: {
ca: fs.readFileSync('server-ca.pem'),
cert: fs.readFileSync('client-cert.pem'),
key: fs.readFileSync('client-key.pem')
}
});
GCP Cloud SQL Proxy (Recommended):
Using Cloud SQL Proxy is more secure and doesn't require public IP:
# Download and run Cloud SQL Proxy
./cloud-sql-proxy --port 3306 PROJECT_ID:REGION:INSTANCE_NAME
# Application connects to localhost:3306
Step 6: Testing and Validation
Thorough testing before going live:
1. Data Integrity Check
-- Compare row counts between source and target
SELECT COUNT(*) FROM your_table;
-- Check checksum
CHECKSUM TABLE your_table;
2. Performance Testing
# Benchmark with sysbench
sysbench oltp_read_write \
--mysql-host=[CLOUD_SQL_IP] \
--mysql-user=root \
--mysql-password=xxx \
--mysql-db=test \
--tables=10 \
--table-size=100000 \
prepare
sysbench oltp_read_write \
--mysql-host=[CLOUD_SQL_IP] \
--mysql-user=root \
--mysql-password=xxx \
--mysql-db=test \
--tables=10 \
--table-size=100000 \
--threads=16 \
--time=60 \
run
3. Application Testing
- Connect test environment to cloud database
- Run complete functional tests
- Load test to confirm it handles expected traffic
MySQL migration looks complicated? With experience it can go smoothly. Schedule migration consultation and let us help plan your migration strategy.
Cloud MySQL Best Practices
After moving to cloud, these settings and habits will make your MySQL run better.
Performance Tuning Tips
1. Adjust Buffer Pool Size
InnoDB buffer pool is key to performance. Cloud services usually auto-configure, but check:
SHOW VARIABLES LIKE 'innodb_buffer_pool_size';
Recommend setting to 70-80% of available memory.
2. Optimize Queries
Analyze slow queries with EXPLAIN:
EXPLAIN SELECT * FROM orders WHERE customer_id = 123;
Ensure frequently used queries utilize indexes.
3. Enable Query Cache (MySQL 5.7)
MySQL 8.0 removed query cache, but 5.7 can still use it:
SET GLOBAL query_cache_type = ON;
SET GLOBAL query_cache_size = 67108864; -- 64MB
4. Connection Pool Settings
Use connection pooling on application side to avoid frequent connection creation:
# Python SQLAlchemy connection pool example
from sqlalchemy import create_engine
engine = create_engine(
'mysql+pymysql://user:pass@host/db',
pool_size=10,
max_overflow=20,
pool_recycle=3600
)
Security Settings (SSL, IAM, Firewall)
1. Enforce SSL Connections
-- Create user that only allows SSL connections
CREATE USER 'app_user'@'%' REQUIRE SSL;
GRANT ALL PRIVILEGES ON your_db.* TO 'app_user'@'%';
2. Principle of Least Privilege
Don't use root for all applications:
-- Create users with only necessary privileges
CREATE USER 'readonly'@'%' IDENTIFIED BY 'password';
GRANT SELECT ON your_db.* TO 'readonly'@'%';
CREATE USER 'app'@'%' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, UPDATE, DELETE ON your_db.* TO 'app'@'%';
3. Network Access Control
- Use Private IP whenever possible, avoid Public IP
- If Public IP is needed, only allow specific IPs
- Use VPC peering to connect other services
Backup and Disaster Recovery Strategy
1. Automatic Backup Settings
All three platforms have automatic backup:
- Set daily backup time (choose off-peak hours)
- Retain at least 7 days, recommend 30 days for important systems
- Regularly test restore to ensure backups work
2. Point-in-Time Recovery (PITR)
If data is accidentally deleted, restore to a specific point in time:
# GCP example
gcloud sql instances clone SOURCE_INSTANCE TARGET_INSTANCE \
--point-in-time '2025-01-15T10:00:00.000Z'
3. Cross-Region Backup
Important systems should enable cross-region backup or read replicas for entire region failure protection.
Monitoring and Alert Configuration
1. Key Metrics Monitoring
Set alerts for these metrics:
- CPU usage > 80%
- Memory usage > 85%
- Storage usage > 80%
- Connections approaching limit
- Replication lag (if using replicas)
2. Slow Query Log
Enable slow query log to find SQL that needs optimization:
SET GLOBAL slow_query_log = 'ON';
SET GLOBAL long_query_time = 2; -- Queries over 2 seconds are slow
3. Use Cloud Monitoring Tools
- AWS: CloudWatch + Performance Insights
- GCP: Cloud Monitoring + Cloud SQL Insights
- Azure: Azure Monitor + Query Performance Insight
Common Problems and Solutions
Connection Troubleshooting
Problem: Can't connect to cloud MySQL
Checklist:
- Is IP whitelist configured?
- Is firewall open for port 3306?
- Is user account configured correctly?
- Is SSL certificate path correct?
# Test connection
mysql -h [CLOUD_SQL_IP] -u root -p --ssl-mode=REQUIRED
# If can't connect, test network first
telnet [CLOUD_SQL_IP] 3306
Problem: SSL certificate error
# Re-download certificates
# GCP
gcloud sql ssl client-certs create CLIENT_CERT_NAME \
--instance=INSTANCE_NAME
# Verify certificate paths
ls -la /path/to/certs/
Performance Issue Diagnosis
Problem: Queries getting slow
-- View currently executing queries
SHOW FULL PROCESSLIST;
-- View slowest queries
SELECT * FROM performance_schema.events_statements_summary_by_digest
ORDER BY SUM_TIMER_WAIT DESC LIMIT 10;
-- Check for lock waits
SHOW ENGINE INNODB STATUS;
Problem: Connection limit reached
-- Check current connections
SHOW STATUS LIKE 'Threads_connected';
-- Check max connections setting
SHOW VARIABLES LIKE 'max_connections';
-- Check connections by user
SELECT user, host, COUNT(*) as connections
FROM information_schema.processlist
GROUP BY user, host;
Solutions:
- Use connection pooling in application
- Upgrade instance specs
- Check for connection leaks
Cost Optimization Tips
1. Choose Right Specs
Don't start with the biggest specs. Start small, monitor for a few weeks, then decide on upgrades.
2. Use Committed Use Discounts
If committed to long-term use, buying 1 or 3 year commitments can save 30-50%.
3. Save on Dev Environments
- Use minimum specs for dev environments
- Can stop instances after hours (note: still charged for storage when stopped)
- Delete after testing, don't leave them running
4. Monitor Idle Resources
Regularly check for unused instances, snapshots, and backups.
Free MySQL Cloud Options
Limited budget? Consider these free options. Detailed list: Free MySQL Cloud Plans List
PlanetScale Free Plan
| Item | Free Quota |
|---|---|
| Storage | 5 GB |
| Reads | 1 billion/month |
| Writes | 10 million/month |
| Branches | 2 (1 production + 1 development) |
PlanetScale is a MySQL-compatible serverless database with generous free quota. Downside is it doesn't support foreign key constraints.
Three Platform Free Tiers
| Platform | Free Content | Duration |
|---|---|---|
| AWS RDS | db.t2.micro 750 hours/month | 12 months |
| GCP Cloud SQL | None ($300 trial credits) | 90 days for credits |
| Azure MySQL | 750 hours/month | 12 months |
AWS and Azure free tiers are for new accounts' first 12 months, then you pay. GCP has no free Cloud SQL, but $300 trial credits can last a while.
FAQ
Can existing MySQL queries be used directly?
Most can. Cloud MySQL uses standard MySQL engine with compatible SQL syntax. But note:
- Confirm MySQL versions match (5.7 or 8.0)
- Some system variables may have restricted modifications
- Some stored procedures may need permission adjustments
Will cloud MySQL have better performance?
Not necessarily. Performance depends on:
- Specs you choose (vCPU, memory)
- Storage type (SSD vs HDD)
- Network latency (distance between application and database)
With same specs, performance should be similar. Cloud's advantage is ability to quickly upgrade specs.
Will migration interrupt service?
Depends on which method you choose:
- mysqldump: Requires downtime, duration depends on data volume
- Replication: Can minimize downtime, only brief interruption during switchover
- Database Migration Service: Supports continuous replication, shortest downtime
For production environments, recommend replication or DMS.
How do I change connection strings after migration?
Main changes:
- Host: Change to cloud MySQL IP or hostname
- Port: Usually still 3306
- SSL: Cloud usually enforces SSL, add certificate configuration
- Connection pool settings: May need adjustment
Conclusion
Moving MySQL to cloud isn't difficult, but needs proper planning.
Migration Checklist
- Assess current database (size, version, connections)
- Choose target platform and specs
- Create cloud MySQL instance
- Choose migration method (mysqldump / DMS / replication)
- Execute data migration
- Update application connection settings
- Test data integrity and performance
- Configure monitoring and alerts
- Configure backup strategy
- Official switchover
Key Takeaways
- Choose the right platform: Based on your cloud ecosystem, whether Taiwan data residency is needed
- Choose the right migration method: Small databases use mysqldump, large databases use DMS or replication
- Test thoroughly: Always test integrity and performance before going live
- Set up monitoring: Continuously monitor after launch, catch issues early
Want to Switch Platforms but Worried About the Hassle?
MySQL cloud migration involves many details:
- Which platform is most suitable?
- How long will migration take?
- How to estimate costs?
- Will performance improve or decline after migration?
CloudInsight Cloud Migration Consultation can help you:
✅ Migration Assessment: Analyze existing database, evaluate migration feasibility and risks ✅ Platform Recommendation: Recommend most suitable cloud platform based on your needs ✅ Cost Estimation: Estimate migration costs and monthly operating expenses ✅ Migration Planning: Create detailed migration plan, minimize downtime ✅ Launch Support: Full assistance during migration process, ensure smooth launch
We have rich MySQL cloud migration experience, providing full assistance from assessment to launch.
Schedule Migration Consultation
Click to schedule 30-minute free consultation
Whether it's your first migration or you want to optimize existing architecture, we can provide professional advice.
Further Reading
- Cloud Database Complete Guide
- Free Cloud Database Complete List
- AWS vs GCP vs Azure Database Complete Comparison
- Google Cloud Database Detailed Tutorial
References
- AWS RDS for MySQL Documentation
- Google Cloud SQL for MySQL Documentation
- Azure Database for MySQL Documentation
- MySQL 8.0 Reference Manual
- Percona - MySQL Performance Tuning
- PlanetScale Documentation
Need Professional Cloud Advice?
Whether you're evaluating cloud platforms, optimizing existing architecture, or looking for cost-saving solutions, we can help
Book Free ConsultationRelated Articles
What is Cloud Database? 2025 Complete Guide | Free Plans, Platform Comparison, Setup Tutorial
Complete analysis of cloud database definition, pros/cons, and use cases. Compare AWS, GCP, Azure platforms, recommend free plans, and step-by-step guide to creating your first cloud database.
Cloud DatabaseGoogle Cloud Database Guide: Firebase & Cloud SQL Complete Tutorial
Complete introduction to Google Cloud database services, including Firebase Realtime Database, Firestore, and Cloud SQL tutorials. From free tiers to enterprise applications - understand everything at once.
Cloud Database2025 Complete Free Cloud Database List | 7 Best Free Options for Beginners
Curated selection of 7 free cloud database options including Firebase, PlanetScale, and Supabase, with detailed free tier comparison tables to help you find the best free solution.