Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Configuring MySQL Flags

Google Cloud SQL supports setting custom MySQL flags that enable you to configure and tune your Google Cloud SQL database. You can use flags, for example, to enable the MySQL slow query log to help spot performance problems, tune max packet sizes, or put the database into read-only mode.

When you configure a supported MySQL flag for an instance, the instance is restarted. The flag value is then persisted for the instance until you remove it. You can configure flags when creating an instance, or for an existing instance by editing it at any time.

You can configure MySQL flags using the Google Developers Console , the Cloud SDK command-line , or using the Google Cloud SQL API .

Contents

Configuring a MySQL flag for an instance

Setting or removing a flag restarts the instance.

Google Developers Console

To set a flag:

  1. Go to the Google Developers Console .
  2. Create a new Developers Console project, or open an existing project by clicking on the project name.
  3. In the sidebar on the left, click STORAGE , and then click Cloud SQL to show a list of Cloud SQL instances for the project.
  4. Click New Instance to create a new Cloud SQL instance in your project. Or, select an existing instance and click Edit .
  5. In the MySQL Flags section, select a value in the Flags box and specify a value.
  6. Continue setting new flags as needed.
  7. Click Confirm to restart the instance with the flag change(s).
  8. On the instance overview page, in the MySQL Flags section there is summary of the flags set.

To remove a flag:

  1. Follow the steps above for setting a flag and click the - (minus sign) next to the flag you want to remove.
  2. Click Confirm to restart the instance.

Cloud SQL Command Line

To set a flag:

  1. Using the Cloud SDK , the following command edits an existing instance:

    $ gcloud sql instances patch your-instance-name --database-flags [flag1=value1 flag2=value2]
    

    For flags that do not take a value, specify the flag name followed by an equals sign ("="). For example, to set the general_log , skip_show_database , and wait_timeout flags, you can use the following command:

    $ gcloud sql instances patch your-instance-name \
    --database-flags general_log=on skip_show_database= wait_timeout=200000
    

  2. To list flags that have been set:
    $ gcloud sql instances get your-instance-name
    

    In the output, database flags are listed under the settings as the collection databaseFlags . For more information on the representation of the flags in the output, see Instances Resource Representation .

To remove a flag:

  1. To clear all flags set on an instance:
    $ gcloud sql instances patch your-instance-name --clear-database-flags
    

    You will be prompted restart the instance.

Cloud SQL API

You can specify custom flags when you create ( insert ) or edit ( patch ) an instance resource. In the examples here, we show how to do this using cURL .

To set a flag for an existing instance:

For example, to set the general_log flag for an existing instance use:

$ curl --header 'Authorization: Bearer accessToken' \
       --header 'Content-Type: application/json' \
       --data '{"settings" : {"databaseFlags" : [{ "name": "general_log",  "value": "on" }]}}' \
       -X PATCH \
       https://www.googleapis.com/sql/v1beta3/projects/your-project-id/instances/your-instance-name

If there are existing custom flags configured for the instance, modify the previous command to include them. The PATCH command will replace the existing flags with the ones specified in the request.

To list flags configured for an instance:

$ curl --header 'Authorization: Bearer accessToken' \
       --header 'Content-Type: application/json' \
       -X GET \
       https://www.googleapis.com/sql/v1beta3/projects/your-project-id/instances/your-instance-name?fields=settings

In the output, look for the databaseFlags field.

Supported Custom MySQL flags

Custom MySQL flags in Google Cloud SQL are a subset of the most commonly requested types of MySQL flags, which include:

  • Server system variables
  • Server command options
  • InnoDB engine startup options and system variables

Note that for a given flag, Cloud SQL may support a different range than the corresponding MySQL variable or option. Also, in some cases, setting one flag may require that you set another flag to fully enable the desired functionality. For example, to enable slow query logging , you must set the slow_query_log flag to on and the log_output flag to TABLE in order to receive log files.

To view the values of custom flags, you can use one of the methods above (see Configuring a MySQL flag for an instance ) as well as logging into your MySQL instance and using SHOW VARIABLES .

MySQL Flag Type Acceptable Values
event_scheduler boolean on | off
general_log boolean on | off
group_concat_max_len numeric 4 .. 17179869184
innodb_flush_log_at_trx_commit enumeration 0 | 1 | 2
innodb_lock_wait_timeout numeric 1 .. 1073741824
log_bin_trust_function_creators boolean on | off
log_output set TABLE | NONE
log_queries_not_using_indexes boolean on | off
long_query_time numeric 0 .. 30000000
lower_case_table_names numeric 0 .. 2
max_allowed_packet numeric 16384 .. 1073741824
read_only boolean on | off
skip_show_database boolean on | off
slow_query_log boolean on | off
If set to on , you must also set the log_output flag to TABLE to receive logs.
wait_timeout numeric 1 .. 31536000
Table 1: Google Cloud SQL Supported MySQL Flags

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.