Google Cloud Platform
Cloud SQL



Getting Started

Data Storage and Replication

Backups and Point-in-Time Recovery

Managing Your Instances

Pricing and Billing

Using Cloud SQL with App Engine


What is Google Cloud SQL?
Google Cloud SQL is a web service that provides a highly available, fully-managed, hosted SQL storage solution for your App Engine applications.

What are the benefits of using Google Cloud SQL?
You can access a familiar, highly available SQL database from your App Engine applications, without having to worry about provisioning, management, and integration with other Google services.

What is Cloud SQL Second Generation?
Cloud SQL Second Generation instance types are the latest version for Google Cloud SQL. These instances support most of the features of first generation instances, but offer higher performance and storage capacity at a lower cost. Advantages of using Cloud SQL Second Generation instances include:
  • Up to 7X throughput and 20X storage capacity of first generation instances
  • Less expensive than First Generation for most use cases
  • Option to add High Availability failover and read replication
  • Configurable backup period and maintenance window

Cloud SQL Second Generation instances require MySQL 5.6. Because they are in beta, they have the following limitations:

  • No Service Level Agreement
  • No point-in-time recovery

Which versions of MySQL are available with Google Cloud SQL? How are updates managed?
Google Cloud SQL offers MySQL 5.5 and 5.6, updated to the current generally available release (see Minor version updates are deployed as they are released, with no further action required on your part.

To see the current version of your instance, go to the Google Cloud Platform Console, select your instance and view the Properties. Or, you can execute SHOW VARIABLES LIKE "%version%"; from a SQL prompt, and look for the value of the version variable.

Does Google Cloud SQL support all the features of MySQL?
In general, Google Cloud SQL supports many of the most common features of MySQL. The following are lists of all the unsupported features and notable differences that Google Cloud SQL has from MySQL.

Unsupported Features:

Unsupported MySQL statements:
Sending any of the following types of SQL statements will generate an error with the message "Error 1290: The MySQL server is running with the google option so it cannot execute this statement"

    • Note: LOAD DATA LOCAL INFILE is supported.

Unsupported MySQL Functions:


Unsupported MySQL Client Program Features:

  • mysqlimport without using the --local option. This is because of the LOAD DATA INFILE restriction. If you need to load data remotely, use the Cloud SQL import function.
  • mysqldump using the --tab option or options that are used with --tab. This is because the FILE privilege is not granted for instance users. All other mysqldump options are supported.

Notable Differences:

  • If you want to import databases with binary data into your Google Cloud SQL instance, you must use the --hex-blob option with mysqldump.

    Although this is not a required flag when you are using a local MySQL server instance and the MySQL command line, it is required if you want to import any databases with binary data into your Google Cloud SQL instance. For more information, see Importing Data.

Are there any size or QPS limits?
There are no queries per second (QPS) limits for Google Cloud SQL instances. However, there are connection, size, and App Engine specific limits in place.

Instance Connections

  • Each tier allows for maximum concurrent connections and queries. For more information, see the pricing page.
  • There is a limit of 100 pending connections independent of tier.
  • Establishing a connection takes, on the server side, about 1.25 ms; because of the 100 pending connection limit, this means a maximum of 800 connection per second. If more than 100 clients try to connect simultaneously then some them will fail.

These limits are in place to protect against accidents and abuse. For questions about increasing these values, contact the team.

Instance Size

The size of all instances is limited to 250GB by default. Note that you only pay for the storage that you use, so you don’t need to reserve this storage in advance. If you require more storage, up to 500GB, then it is possible to increase limits for individual instances for customers with a Silver or higher Google Cloud support package.

Google App Engine Limits

Requests from Google App Engine applications to Google Cloud SQL are subject to the following time and connection limits:

  • All database requests must finish within the HTTP request timer, around 60 seconds. For more information, see for example, HTTP request timer in the App Engine Java Developer Guide.
  • Offline requests like cron tasks have a time limit of 10 minutes. For more information, see for example, Scheduled Tasks with Cron for Java in the App Engine Java Developer Guide.
  • Requests from App Engine modules to Google Cloud SQL are subject to the type of module scaling and instance residence time in memory. For more information, see for example, App Engine Modules in Java in the App Engine Java Developer Guide.
  • Each App Engine instance cannot have more than 12 concurrent connections to Cloud SQL.

Google App Engine applications are also subject to additional Google App Engine quotas and limits as discussed on the Quotas page.

How can I be notified when there are any changes to Google Cloud SQL?
You can sign up for the google-cloud-sql-announce forum where we post announcements and news about Google Cloud SQL.

How can I cancel my Google Cloud SQL account?
You can deactivate Google Cloud SQL for a project by visiting the Google Cloud Platform Console, selecting the project, selecting the API service, and then selecting Enabled APIs. Find the Google Cloud SQL service and click Disable for that service.

How do I report a bug, request a feature, or ask a question?
You can report bugs and request a feature on our project page. You can ask a question in Stack Overflow. For other support options, see the Google Cloud SQL Support page.

Why is my instance suspended?
This is probably because billing is not enabled, or there is an issue with your account.

What are the known issues?
See the known issues list on our project page.

Getting Started

What is the best tool to use for managing my instance?
There are a variety of tools available for Google Cloud SQL. For executing simple statements, you can use the MySQL Command-Line Tool. For executing more complicated tasks or to use a richer database development environment, you can try Toad for MySQL or MySQL Workbench. For more information, see Admin and Reporting Tools.

What storage engine should I use?
InnoDB is the default storage engine in MySQL 5.5 and 5.6, and is also the recommended storage engine for Google Cloud SQL because it has significantly better performance and durability. If you do not need any features that require MyISAM, such as full text search in MySQL 5.5, you should use InnoDB.

Warning: Using the MyISAM storage engine could result in data loss in some situations, such as unclean shutdowns. For more information, Corrupted MyISAM Tables.

If you would like to use features of MyISAM, try to use it for just those tables that require it. You can convert an existing table to MyISAM using the following SQL command, replacing tablename with the name of the table to convert:


If you have a mysqldump file where all your tables are in MyISAM format, you can convert them to InnoDB format by piping the file through a sed script:

mysqldump --databases database_name [-u username -p password] --hex-blob --default-character-set=utf8 |
sed 's/ENGINE=MyISAM/ENGINE=InnoDB/g' > database_file.sql

Warning: You should not do this if your mysqldump file contains the mysql schema. Those files must remain in MyISAM.

I've just created a new, empty, instance but the dashboard shows I have already used some disk space. Why?
The InnoDB storage engine creates initial log and data files when your instance is created.

Why is my First Generation instance sometimes slow to respond?
In order to minimize the amount you are charged for instances on per-use billing plans, by default your instance becomes passive if it is not accessed for 15 minutes. The next time it is accessed there will be a short delay while it is activated. You can change this behavior by configuring the activation policy of the instance. Learn more.
Which activation policy should I use?
If you are using a Second Generation instance, or a First Generation instance with the Package billing plan, you should set your activation policy to ALWAYS, because there is no cost benefit to turning off your instance when it is not being used.

If you are using a First Generation instance with the Per-Use billing plan, you can reduce your costs by setting your activation policy to ON DEMAND. This setting causes your instance to automatically shut itself off after 15 minutes of inactivity, so you are not incurring charges when the instance is not in use.

When your instance has an activation policy of ON DEMAND, there is a small delay for any access request that comes in when the instance is off, because the instance must start up before servicing the request.

Data Storage and Replication

Where is my data stored?
Data for a Google Cloud SQL instance is stored in zones in the United States, European Union, or Asia depending on the location that you select when creating the instance. Data at rest in the United States or European Union regions is kept within its region. This guarantee cannot be made for instances created in Asia.

What is a zone?
A zone is an independent entity in a specific geographical location where you can run your resources. For example, a zone named us-central1-a indicates a location in the central United States. Data in Google Cloud SQL is replicated, and the service is distributed, across multiple zones, so to be tolerant of the failure of any single zone. For more information see Zone Resources in the Google Compute Engine documentation.

What are the limits on storage?
The size of all instances is limited to 250GB by default. Note that you only pay for the storage that you use, so you don’t need to reserve this storage in advance. The limits on storage are determined by the time it takes to restore an instance from backup in case of a problem, and we cannot guarantee to restore instances larger than 250GB within 24 hours (smaller instances restore a lot faster). If you require more storage, up to 500GB, then it is possible to increase limits for individual instances for customers with a Silver or higher Google Cloud support package.

How is my data replicated?
When creating a Google Cloud SQL instance, you can choose to enable synchronous or asynchronous replication for your data. In either case, your data is replicated in multiple zones within the US, EU, or Asia locations. This is equivalent to taking a backup of any updates to your data as they happen. This means that in the very unlikely event of a complete failure of a zone, your data will be preserved. In synchronous replication, your updates are copied to multiple zones before returning to the client. This is great for reliability and availability in the event of major incidents, but makes writes slower. The asynchronous replication option increases write throughput by acknowledging your write once it is cached locally, but before copying the data to other locations. Asynchronous replication results in faster writes to the database because you don't have to wait for replication to finish; however, you might lose your latest updates in the unlikely event of a data center failure within a few seconds of updating the database. Choosing synchronous or asynchronous replication makes no difference to how much you are billed because replication is not charged.

How does Google Cloud SQL failover work?
All Cloud SQL data is replicated in multiple zones. In the unlikely event of a zone outage, instances fail over to another, available, zone automatically. Failover is designed to be transparent to your applications, so that after failover, an instance has the same instance name, IP address, and firewall rules. During the failover there will a few minutes of downtime while your instance starts up in the new zone.

In a failover event, existing connections to instances are broken. You can test how your application responds to a failover by restarting your instance. For recommendations on managing connections that can help in failover events, see the FAQ entry How should I manage connections?

Is my data encrypted?
Yes. Cloud SQL customer data is encrypted when on Google’s internal networks and when stored in database tables, temporary files, and backups.

External connections can be encrypted using SSL. Of course you can also encrypt your data yourself before writing it to Cloud SQL, though this would require you to manage your own keys.

How is encryption managed?
Your data is encrypted using the 256-bit Advanced Encryption Standard (AES-256), or better, with symmetric keys: that is, the same key is used to encrypt the data when it is stored, and to decrypt it when it is used. These data keys are themselves encrypted using a master key, stored in a secure keystore, and changed regularly.

Is my data encrypted when it’s on Google’s internal network?

Backups and Point-in-Time Recovery

How do I recover an instance?
To restore to a backup you can use the Google Cloud Platform Console or the Cloud SQL command-line tool. For more details, see Restoring from Backups.

To restore to a point-in-time, you can use the Cloud SQL command-line tool. For more information, see Performing a Point-in-Time Recovery.

How much do backups cost?
Storage of 7 days of backups are included in the cost of your instance. Binary log space counts toward the storage used in an instance. Restoring from an instance backup restores to the instance. Recovering an instance to a point-in-time creates a new instance, which will be charged at the standard instance rate. For more information about instance storage pricing and instance rates, see Pricing.

How do I enable point-in-time recovery?
Point-in-time recovery is not enabled by default. You must enable automated backups and binary logging for an instance to use point-in-time recovery. For more information, see Backup and Recovery.

How does point-in-time recovery impact performance?
Point-in-time recovery requires that you enable binary logging. This means that every update to your database is written to an independent log, which involves a small reduction in write performance. Reads are unaffected. The impact on performance is greater for instances that use synchronous replication, so we recommend that binary logging is used together with asynchronous replication.

Managing Your Instances

Can I make my database larger or smaller by changing between tiers?
Yes. You can change the tier of your database at any point. Note that this will force your instance to restart, which will take a few seconds.

Do I need to use the Google Cloud Platform Console to manage Google Cloud SQL?
No. All management tasks that can be done via the console can also be done programmatically via the Cloud SQL API.

How large a database can I use with Google Cloud SQL?
Currently, your database instance can be no larger than 500GB.

How can I reclaim the space from a dropped table?
When you drop a table from a database and then check the Google Cloud Platform Console, you will see that the space freed by dropping the tables is not reflected in the reported Storage Used of the instance. For performance reasons, we run with innodb_file_per_table=OFF and InnoDB never shrinks its default tablespace. Therefore, to reclaim space, recreate a new instance from the smaller database.

How can I track changes to data?
To track changes to data, enable binary logging for your instance. Tracking changes to data can help you recover from accidental data loss. In the event of accidental data loss such as from a DROP DATABASE command, you can restore up to the binary log coordinates just before the data loss event. For more information, see point-in-time recovery.

What kind of maintenance shutdowns should I expect with my instance?
We periodically restart Cloud SQL instances to perform upgrades, migrate between zones, and perform other infrastructure work. Since your data is replicated in multiple locations, the interruption to your instances is typically a few seconds to a few minutes. Instances configured to follow an App Engine application may also be restarted in a new location in order to minimize the latency from that application as it moves. This may involve a short period of increased latency, and typically a few seconds of unavailability.

We recommend that you design your applications to deal with situations when your instance is not accessible for short periods of time, such as in a maintenance shutdown. You can test the behavior of your application to a maintenance shutdown by restarting your instance, which has the same effect. In general, we recommend that you use only short-lived connections as well as use exponential back-off for retrying rejected connections. For more guidance see How should I manage connections?

Note that the amount of time mysqld has to shutdown is capped to 1 minute. If the shutdown does not complete in that time, the mysqld process is forcefully terminated. This will incur a longer startup time because the InnoDB storage engine does a crash-recovery before the server is ready to start serving queries. The time for a crash-recovery to complete depends on the size of the database; larger databases require more time for recovery.

Can I import or export a specific database?
Yes, you can import or export a specific database or all databases on an instance. For more information, see Importing and Exporting Data.

Can I import or export a CSV file?
Yes, you can import or export a CSV file. For more information, see Importing and Exporting Data.

Do I need a Google Cloud Storage account to import or export data to an instance?
You can import and export databases to instances using mysqldump files and standard tools, such as MySQL Client, that do not require a Google Cloud Storage account. Note that some options of the mysqldump tool are not supported by Google Cloud SQL. For more information, see MySQL features supported by Google Cloud SQL.

Cloud SQL supports importing and exporting databases (compressed or uncompressed mysqldump files) and CSV files using a Google Cloud Storage bucket. To import or export using a Google Cloud Storage bucket, you need to either sign up for a Cloud Platform account and create a bucket, or have access to a Google Cloud Storage bucket in another account. For more information, see Importing and Exporting Data.

If I delete my instance, can I reuse the instance name?
Yes, but not right away. The instance name is unavailable for up to a week before it can be reused.

A 'gserviceaccount' is shown in the team members in the console. What is it?
This account was created automatically and is used by Google to manage your Cloud SQL instance, but has no effect on your project. (For example, it does not matter if you alter the permissions on this account.)

What is the cloudsqladmin database user?
Every Google Cloud SQL instance includes a database user called cloudsqladmin. You may notice this user if you do a SHOW GRANTS FOR cloudsqladmin@localhost. On some instances this will also show up in the mysql.user table. This user account is used by automated processes that need to access the data in your instance (for example, backing up your instance or performing an import or export).

How can I use GRANT ALL?
Google Cloud SQL does not support SUPER privileges, which means that GRANT ALL PRIVILEGES statements will not work. As an alternative, you can use GRANT ALL ON `%`.*.

How can I access transaction logs for my instances?
If you enable binary logging for your instance (see Enabling binary logging for a Cloud SQL instance) and configure an IP address for you instance (see Configuring access control for IP connections), then you can use the standard MySQL mysqlbinlog utility to examine the transaction logs for the instance.

Pricing and Billing

How can I try out Google Cloud SQL?
The D0 tier and per-use billing means that you can try out the service for just $0.025/h, and you only pay this while the instance is being used.

Which pricing plan should I use? Per-use or package?
This depends on how your database will be used, but as a rule of thumb it is more economical to opt for the package plan if your instance is used for more than 450 hours each month.
See Pricing for details of the pricing plans.

Can I change between plans?
You can change the billing plan for your instance up to 3 times per month. The plan in effect at the end of the day (US Pacific Time) will be the one used to calculate the charge for your instance. You can change your plan as many times as you like in a single day, and it counts as one of your three monthly changes.

You can change the billing plan for an instance by editing its settings. Do this by going to the Google Cloud Platform Console, selecting the project that contains the instance, and then selecting Google Cloud SQL. From the list of instances, select one and edit its settings, which includes billing settings.

How many instances can I create in a project?
You can create up to 30 instances per project. Deleted instances do not count toward the 30 instance limit. You can request that the instance limit be raised for a project.

What size database instance do I need? How much RAM?
If you already know approximately how much data you will have then the fixed package sizes are a good guide to a suitable instance size. You can increase the performance of your database in general by choosing a larger instance with more RAM and CPU. This will increase the performance of many queries that involve large amounts of computation, such as those involving joins, ORDER BYs, or GROUPing, though the performance of updates affecting single rows will not be much affected.

How is use of my instance calculated?
If your instance is billed per use, then you will be charged for each hour of the day your database is up. For example:
  • If your instance was up from 09:10 - 09:40, you are charged for one hour because the instance was up during the hour 09:00 - 09:59.
  • If your instance was up from 10:30 - 11:20, you are changed for two hours because the instance was up during the hours 10:00 - 10:59 and 11:00 - 11:59.
  • If your instance was up from 12:00 - 12:20 and 12:30 - 12:50, you are changed for one hour because the instance was up only during the hour 12:00 - 12:59.

Billing charges are calculated using US Pacific Time.

By default, your instance is spun up whenever you access it (whether from a SQL prompt, an external application, or from an App Engine application), and remains up for 15 minutes after the completion of the last access. After this time, the instance is shut down. You will not be charged for the time your database is not up.

Note that an instance stays up as long as there are clients connected to it. This includes idle connections. You can list the connections to an instance using the MySQL client and executing the SHOW PROCESSLIST command. You can then use the KILL command to kill connections. You can also you restart the instance to kill all the connections.

By default, package instances stay up for 12 hours after the last access.

You can change the activation behavior of an instance by modifying its activation policy. Learn more.

How is storage calculated?
Storage is calculated on the basis of the amount of file space used by your MySQL instance. Storage is charged per GB in hour units (whether the database is up or not) measured as the largest number of bytes during that period, rounded up to the nearest GB. Storage for backups created using the scheduled backup service is not charged.

How can I see how much I will be charged?
The Billing tab of the Google Cloud Platform Console shows you how much charge your instances have gathered since the last bill was issued.

I have not been using my instance recently, so why have I been charged for it even though I am on the "per-use" plan?
Check to see if you have enabled scheduled backups for the instance. Google Cloud SQL takes a backup of an instance only if the instance's data has changed since the last scheduled backup. Whenever a scheduled backup occurs, the instance is activated for the duration of the backup, incurring "per-use" fees.

Why have I have been billed for more time than my database instance has been used?
The "per-use" plan bills for the time that your database instance is used. Each use is rounded up to the nearest hour. So if you use your instance for five minutes once an hour for ten hours, you will be billed for ten hours of use.

What happens when my instance reaches the allowed size?
If your instance reaches the maximum storage amount allowed by the plan you have chosen, future writes to the database are disallowed until you delete data to reduce the size.

How do I disable billing?
You can disable billing by clicking Disable billing in the Google Cloud Platform Console Billing & settings pane for a project. If you disable billing, you also disable the Google Cloud SQL service. Make sure you really want to disable the Google Cloud SQL service before you disable billing.

After you disable billing, you will receive one last bill for charges that occurred between the beginning of the billing cycle and when you cancelled.

What kind of read replicas can I create?
You can configure:
  • Cloud SQL instances that replicate from a Cloud SQL master instance.
  • Cloud SQL instances that replicate from an external master instance.
  • External MySQL instances that replicate from a Cloud SQL master instance.

Note that external read replica instances must:

  • Be able to connect to the Cloud SQL master instance with the MySQL wire protocol.
  • Support row-based replication.
  • Be the same (or later) version of the Cloud SQL instance being replicated.

For more information about read replicas, including use cases for each type, see Configuring Replication with Google Cloud SQL.

How can I tell if an instance is a read replica?
You can use the Google Cloud Platform Console to see all of your Cloud SQL instances, and whether an instance is a master or read replica instance. You can use the Cloud SDK to check whether an instance is a master or read replica. For more information, see Checking replication status.

Using Google Cloud SQL with App Engine

Can my App Engine in the US access my Google Cloud SQL instance in the EU (and vice versa)?
No. App Engine applications in the US can only access Google Cloud SQL instances in the US. Similarly, App Engine applications in the EU can only access Google Cloud SQL instances in the EU.

Should I use Google Cloud SQL or the App Engine Datastore?
This depends on the requirements of the application. Datastore provides NoSQL key-value storage that is highly scalable, but does not support the complex queries offered by a SQL database. Cloud SQL supports complex queries and ACID transactions, but this means the database acts as a 'fixed pipe' and performance is less scalable. Many applications use both types of storage.

Should I use Google Cloud SQL with my Master-Slave App Engine application?
We recommend that you use Google Cloud SQL with High Replication (HRD) App Engine applications. While you can use Google Cloud SQL with applications that do not use high replication, doing so might impact performance.

Do I need to install a local version of MySQL to use the App Engine Development Server?
No. You can configure App Engine to use either Cloud SQL or a locally installed version MySQL when running on the development server. Note, however, that using a locally-installed version of MySQL helps reduce usage of your App Engine datastore quota during testing.

What languages can I use to access my instance?
Google App Engine supports several languages that you can use to connect to your instances. For more information, see Connecting to Google Cloud SQL from Google App Engine.

If you are not using Google App Engine, you can use any language that has an associated MySQL connector or API. For a list of supported languages, see the Connectors and APIs chapter in the MySQL Reference Manual.

Can I use Django with Google Cloud SQL?
Yes, Google Cloud SQL is compatible with Django! See the Django Support documentation for details.

Which placeholders can I use in my Python query string?
Python users can only use the %s format code in parameter substitution. Therefore, the following statement is invalid: cursor.execute('INSERT INTO entries (guestAge) VALUES (%d)', (age)).

How should I manage connections?
How to best manage your database connections depends on your use case but, in general, we recommend using connection pooling. Connection pooling will protect the database server from large numbers of new connections created too rapidly, which can impact performance.

In cloud-hosted environments, you should manage your database connections differently than managing them in a conventional, external server environment. We recommend that you design your applications to handle occasional connection failures by implementing an error handling strategy like exponential backoff. For an example, see Exponential backoff in the Google Cloud Storage documentation.

To learn more about instance connection limits, see the FAQ Are there any size or QPS limits?

What does a SQLException with message of "Invalid connection ID" mean?
It means that the connection is no longer open on the server and should be discarded by the client.  You do not need to call 'close' on these connections; they are already closed.

Can I access my Google Cloud SQL instance programmatically outside of App Engine?
Yes. You can access Google Cloud SQL instances programmatically from external applications using JDBC, including writing Apps Script scripts to access your Google Cloud SQL databases. See Connecting from External Applications.