A shell-based project to automate the setup and configuration of a MySQL server on Google Cloud Platform (GCP). This repository includes scripts and SQL schema files to initialize a scalable MySQL instance and configure databases and users.
Features
- Automates creation of a MySQL 8.0 Cloud SQL instance on GCP
- Sets up database users with appropriate permissions
- Provides SQL schema files for blog-related tables (posts, authors, mastodon_posts, builds, feed)
- Includes configuration and initialization scripts
Tech Stack
- Shell scripting (Bash) for automation
- Google Cloud SDK (
gcloud) for managing GCP resources - MySQL 8.0 as the database engine
Getting Started
Prerequisites
- Google Cloud SDK installed and authenticated (
gcloud auth login) - A GCP project with billing enabled
- Environment variables set in a
.envfile (e.g.,ROOT_PASSWORD,COBRA_PASSWORD)
Installation & Usage
- Clone the repository:
git clone https://github.com/justin-napolitano/setup-mysql-gcp.git
cd setup-mysql-gcp
-
Set up your
.envfile with necessary credentials. -
Run the initialization script to create and configure the Cloud SQL instance:
bash gcp_initialize_mysql_server.sh
- Use the SQL schema files in
mysql-config/to create tables and databases as needed.
Project Structure
setup-mysql-gcp/
├── gcp_initialize_mysql_server.sh # Bash script to initialize MySQL instance on GCP
├── index.md # Blog post describing the automation process
└── mysql-config/ # Folder containing SQL schema and configuration files
├── authors.sql # Authors table schema
├── builds.sql # Builds table schema
├── feed.sql # Feed table schema
├── mastodon.sql # Mastodon posts table schema
├── posts.sql # Posts table schema
└── index.md # MySQL server configuration notes
Future Work / Roadmap
- Add error handling and validation in the initialization script
- Automate deployment of SQL schema files after instance creation
- Expand user management with role-based access control
- Integrate CI/CD pipelines for automated testing and deployment
- Document backup and restore procedures for the Cloud SQL instance
Note: This project assumes familiarity with GCP, MySQL, and shell scripting.