Today we’ll be setting up our database on the Google Cloud Platform. We’ll be using MySQL. If you haven’t already setup a GCP account, you’ll need to do that first. Fortunately, Google offers a one time $300/12 month credit free trial, see the FAQ. I used up my trial a ways back, so I’ve already setup my billing account with that in mind. There’s info on the aforementioned FAQ for setting up your billing account if you can’t use the free trial.
If you’re a read first kind of person, feel free peruse the GCP MySQL documentation.
Lets jump right in 🙂 . On the projects page, lets create a project and call it mybooks. After creating the project, it’ll take a minute or so for GCP to complete the setup. You’ll know its complete when the notification icon on the toolbar switches to the message count. You can either click the notification message, or navigate to the console, if you have other projects, you may have to select mybooks from the project dropdown on the toolbar (next to the Google Cloud Platform label).
I’ve already setup my billing, so I’ll skip that step, but you’ll need to do so if you haven’t already. See the FAQ or the GCP MySQL documentation for more info. Also, if you’ve been playing around and have turned off a card that I use later on, you can turn them back on via the Customize action available on right side of the tab bar.
From the products and services dropdown (the hamburger button under the cursor in the image):
Select SQL then Create Instance. Choose MySQL as your database engine. In the instance type selection, Choose Second Generation, and you should end up on the Generation instance page:
There are a lot of interesting things going on here, but if we dive into everything interesting, we’ll never get anything done. So get to it:
- Instance ID: this will affect how we connect to the database later, my preference is to spell out that its a db instance to make it stand out from the project, so lets name it mybooks-db.
- Database version: we’ll leave at MySQL 5.7.
- Location: Leave the location at the google default. Depending on your location and situation, you most likely will have a different value than mine. Since this is just a tutorial, it doesn’t much matter, but it can have some pretty significant latency implications in production situation. Hopefully you’ll have become a lot more familiar with GCP by then 😉 .
- Machine Type: Since this is just a tutorial, let’s change this to db-f1-micro. The webservices and data we’ll be deploying are pretty minimal, so that should be sufficient and save us some money.
- Storage Type: Again, we’re trying to save money for the important stuff in life, so select HDD.
- Storage capacity: The default 10GB is fine for the minimal amount of data we’ll be using.
- Enable automatic storage increase: If this were something other than a tutorial, I’d allow for automatic storage increases, but for our purposes (money, honey) we’ll turn off automatic storage increase. Learn more at your leisure 🙂 .
- Disk Throughput and IOPS: If you’re worried about the disk throughput and the IOPS, don’t be. This is a simple web service we’ll be supporting, and the IOPS calculations are done assuming 16KB per operation. We’ll be pushing around significantly less than that.
- Backups and binary logging: The defaults are fine (Automate backup checked, Enable binary logging checked, Create failover replica unchecked).
- Maintenance window and timing: Again the defaults are fine (Any window, and Any timing).
- Root Password: Don’t pick something stupid. Use the generator or find a secure password manager. Store it securely, you’ll need it.
- For now we won’t add any Cloud SQL flags or Authorized networks.
Tomorrow we’ll connect our tools to the db, create the schema, and insert some test data.