BlueXP Blog

Google Cloud SQL: MySQL, Postgres and MS SQL on Google Cloud

Written by Yifat Perry, Technical Content Manager | May 1, 2020 4:00:00 AM

Google Cloud SQL is a managed Google Cloud database service that allows you to run MySQL, PostgreSQL and Microsoft SQL Server databases on Google Cloud.

In this post, we’ll give you a well-rounded introduction to the service, explaining what Google provides for each type of database, the costs, and how to start your first database. In addition, we’ll show how NetApp Cloud Volumes ONTAP can help optimize and reduce costs for database storage on Google Cloud.

In this article, you will learn:


What Is Google Cloud SQL?

Google Cloud SQL is a fully-managed service that you can use for relational databases in Google Cloud. It is compatible with SQL, MySQL, and PostgreSQL and can be connected to almost any application. The service provides automated backups, replication, and failover to ensure high-availability and resilience. It provides an easy and fast way to deploy and operate an SQL database in your cloud. 

Features of Google Cloud SQL include: 

  • Automatic data encryption and support for private networks
  • Integration with App Engine, Compute Engine, and Google Kubernetes Engine
  • Support for Java, Python, Ruby, PHP, Node.js, and Go
  • Support for analytics through BigQuery

Cloud SQL Services Compared

When deciding which database type is best suited for your needs, it’s helpful to understand how your options compare. Below is a breakdown of some of the most important differences.

  MySQL

PostgreSQL

SQL Server

Description

MySQL Community Edition

PostgreSQL based on the Cloud SQL Second Generation platform.

Standard SQL Server

Resources

Instances support v5.6 and up with up to 416 GB RAM and 30 TB storage. These instances can be autoscaled.

Custom instances provide up to 416 GB RAM, 64 CPUs, and 30 TB of storage. These instances can be autoscaled.

Custom instances provide up to 416 GB RAM, 64 CPUs, and 30 TB of storage. These instances can be autoscaled.

Can be used
  • Third-party tools, including Toad for MySQL and SQL Workbench

  • External applications

  • Applications on App Engine, Compute Engine, GKE

  • Cloud Functions

  • Cloud Run

  • Google Apps Script

  • Third-party tools via the standard PostgreSQL client-server protocol

  • External applications

  • Applications on App Engine, Compute Engine, GKE

  • Cloud Functions

  • Cloud Run

App Engine applications only

Google Cloud SQL Pricing

Google Cloud SQL has a different pricing model for each database service.

Google Cloud SQL server pricing

  • Cost per vCPU starting from $0.059
  • Cost per memory starting from $0.01 per GB
  • Storage cost starting from $0.17 per GB/month
  • Network egress cost starting from $0.12/GB ($0.05/GB using Cloud Interconnect)
  • Licensing costs ranging between $0-$0.47 per core hour

Google Cloud MySQL second-generation pricing

  • Storage cost starting from $0.09 per GB/month
  • Network egress cost starting from $0.12/GB ($0.05/GB using Cloud Interconnect)
  • Cost per database instance between $0.015-$8.048 per hour 

Google Cloud PostgreSQL pricing

  • Cost per vCPU starting from $0.059
  • Cost per memory starting from $0.01 per GB
  • Storage cost starting from $0.17 per GB/month
  • Network egress cost starting from $0.12/GB ($0.05/GB using Cloud Interconnect)
  • Cost per database instance between $0.0105-$0.035 per hour

How to Create Your First Cloud SQL Instance Using the Google Cloud Console

Setting up an SQL instance is relatively straightforward. You can follow the tutorial below to set up a MySQL instance. If you wish to set up PostgreSQL or SQL instead, you can follow the Google tutorials linked here.

1. Setup and requirements

To get started, you need to have a Google Account. If you don’t have one, you need to first create one. Next, you need to sign into the Google Cloud Platform Console and create a new project. In the console, you also need to enable billing so you can use cloud resources.

2. Open the Cloud SQL web UI

In the console side menu, select SQL from the Storage subsection.

Source: Google

This brings up the Cloud SQL user interface. Since you are starting a new project, you should see a dialog box that you can use to create a new SQL instance.

3. Create a new instance

Select the Create instance button. Previously, there were two instance types you could choose for MySQL. Now, only second-generation instances are available. If you have existing first-generation instances, you can leave instances as is or upgrade. However, any new instances you create must be second-generation.

Source: Google

In the creation screen, you are prompted to enter details for your instance. These details include:

  • Instance ID—must be a unique identifier within your project. You can use the same name in other projects, but it is not recommended for clarity.
  • Password—you can opt-out of creating a password, but this is not recommended.
  • Location—including region and zone.
  • Database version—either 5.6 or 5.7.

Once you have entered your details and recorded your password in a safe location, click Create. This returns you to the instances list where you can select your instance to see its details. Note that instance initialization and startup typically take a few minutes to complete.

4. Create a database with Cloud Shell

Once your instance is ready, you can connect to it and create your database. To do this, in the console, click the Activate Google Cloud Shell button.

Source: Google

Since this is a new project, you need to click Start Google Shell when prompted. Once the shell pops up, you can connect to your instance with the following command:

gcloud sql connect {Instance name} --user=root

You should be prompted to enter your root password. Once entered, you can create your database with the following command:


mysql> CREATE DATABASE {Database name};
Query OK, 1 row affected (0.00 sec)

After database creation, you can begin entering or importing data as needed.

Google Cloud Database Storage with Cloud Volumes ONTAP

NetApp Cloud Volumes ONTAP, the leading enterprise-grade storage management solution, delivers secure, proven storage management services on AWS, Azure and Google Cloud. Cloud Volumes ONTAP supports up to a capacity of 368TB, and supports various use cases such as file services, databases, DevOps or any other enterprise workload, with a strong set of features including high availability, data protection, storage efficiencies, Kubernetes integration, and more.

In particular, Cloud Volumes ONTAP helps in addressing database workloads challenges in the cloud, and filling the gap between your cloud-based database capabilities and the public cloud resources it runs on.