設定資料庫旗標

本頁說明如何設定 Cloud SQL 的資料庫旗標,並列出可為執行個體設定的旗標。您可以使用資料庫標記執行許多作業,包括調整 MySQL 參數、調整選項,以及設定和調整執行個體。

在部分情況下,設定某一標記可能會需要您設定另一個標記,才能完整啟用想要使用的功能。例如,如要啟用慢速查詢記錄,您必須將 slow_query_log 標記設為 on,並將 log_output 標記設為 FILE,才能透過 Google Cloud 控制台的記錄檔探索工具使用記錄。

設定、移除或修改資料庫執行個體的標記時,資料庫可能會重新啟動。移除之前,系統都會保留執行個體的旗標值。如果執行個體是副本的來源,且執行個體已重新啟動,副本也會重新啟動,以配合執行個體的目前設定。

設定資料庫旗標

下列各節將說明常見的旗標管理工作。

設定資料庫旗標

控制台

  1. Google Cloud 控制台中,選取包含要設定資料庫旗標的 Cloud SQL 執行個體的專案。
  2. 開啟執行個體並按一下 [編輯]
  3. 前往「旗標」部分。
  4. 如要設定先前未在執行個體上設定的標記,請按一下「新增項目」,從下拉式選單中選擇標記,然後設定其值。
  5. 按一下 [儲存] 以儲存變更。
  6. 在「總覽」頁面的「標記」下方,確認您所做的變更。

gcloud

編輯執行個體:

gcloud sql instances patch INSTANCE_NAME --database-flags=FLAG1=VALUE1,FLAG2=VALUE2

這項指令會覆寫先前設定的所有資料庫標記。如要保留這些標記並新增標記,請加入要在執行個體上設定的所有標記值;任何未明確加入的標記都會設為預設值。對於未設定值的旗標,請指定旗標名稱,然後加上等號「=」。

舉例來說,如要設定 general_logskip_show_databasewait_timeout 旗標,可以使用下列指令:

gcloud sql instances patch INSTANCE_NAME \
  --database-flags=general_log=on,skip_show_database=on,wait_timeout=200000

Terraform

如要新增資料庫旗標,請使用 Terraform 資源

resource "google_sql_database_instance" "instance" {
  database_version = "MYSQL_8_0"
  name             = "mysql-instance"
  region           = "us-central1"
  settings {
    database_flags {
      name  = "general_log"
      value = "on"
    }
    database_flags {
      name  = "skip_show_database"
      value = "on"
    }
    database_flags {
      name  = "wait_timeout"
      value = "200000"
    }
    disk_type = "PD_SSD"
    tier      = "db-n1-standard-2"
  }
  # set `deletion_protection` to true, will ensure that one cannot accidentally delete this instance by
  # use of Terraform whereas `deletion_protection_enabled` flag protects this instance at the GCP level.
  deletion_protection = false
}

套用變更

如要在 Google Cloud 專案中套用 Terraform 設定,請完成下列各節的步驟。

準備 Cloud Shell

  1. 啟動 Cloud Shell
  2. 設定要套用 Terraform 設定的預設 Google Cloud 專案。

    每項專案只需要執行一次這個指令,且可以在任何目錄中執行。

    export GOOGLE_CLOUD_PROJECT=PROJECT_ID

    如果您在 Terraform 設定檔中設定明確值,環境變數就會遭到覆寫。

準備目錄

每個 Terraform 設定檔都必須有自己的目錄 (也稱為根模組)。

  1. Cloud Shell 中建立目錄,並在該目錄中建立新檔案。檔案名稱的副檔名必須是 .tf,例如 main.tf。在本教學課程中,這個檔案稱為 main.tf
    mkdir DIRECTORY && cd DIRECTORY && touch main.tf
  2. 如果您正在學習教學課程,可以複製每個章節或步驟中的範例程式碼。

    將範例程式碼複製到新建立的 main.tf

    視需要從 GitHub 複製程式碼。如果 Terraform 代码片段是端對端解決方案的一部分,建議使用這個方法。

  3. 查看並修改範例參數,套用至您的環境。
  4. 儲存變更。
  5. 初始化 Terraform。每個目錄只需執行一次這項操作。
    terraform init

    如要使用最新版 Google 供應商,請加入 -upgrade 選項:

    terraform init -upgrade

套用變更

  1. 檢查設定,確認 Terraform 即將建立或更新的資源符合您的預期:
    terraform plan

    視需要修正設定。

  2. 執行下列指令,並在提示中輸入 yes,即可套用 Terraform 設定:
    terraform apply

    等待 Terraform 顯示「Apply complete!」訊息。

  3. 開啟 Google Cloud 專案即可查看結果。在 Google Cloud 控制台中,前往 UI 中的資源,確認 Terraform 已建立或更新這些資源。

刪除變更

如要刪除變更,請按照下列步驟操作:

  1. 如要停用防刪除功能,請在 Terraform 設定檔中將 deletion_protection 引數設為 false
    deletion_protection =  "false"
  2. 執行下列指令,並在提示中輸入 yes,套用更新的 Terraform 設定:
    terraform apply
  1. 執行下列指令,並在提示中輸入 yes,即可移除先前透過 Terraform 設定套用的資源:

    terraform destroy

REST v1

如要為現有資料庫設定旗標,請按照下列步驟操作:

使用任何要求資料之前,請先替換以下項目:

  • project-id:專案 ID
  • instance-id:執行個體 ID

HTTP 方法和網址:

PATCH https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id

JSON 要求主體:

{
  "settings":
  {
    "databaseFlags":
    [
      {
        "name": "flag_name",
        "value": "flag_value"
      }
    ]
  }
}

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

舉例來說,如要為現有資料庫使用設定 general_log 標記:

使用任何要求資料之前,請先替換以下項目:

  • project-id:專案 ID
  • instance-id:執行個體 ID

HTTP 方法和網址:

PATCH https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id

JSON 要求主體:

{
  "settings":
  {
    "databaseFlags":
    [
      {
        "name": "general_log",
        "value": "on"
      }
    ]
  }
}

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

如果資料庫目前已設有標記,請修改前一指令以併入這些標記。PATCH 指令會以要求中指定的值覆寫現有的標記。

REST v1beta4

如要為現有資料庫設定旗標,請按照下列步驟操作:

使用任何要求資料之前,請先替換以下項目:

  • project-id:專案 ID
  • instance-id:執行個體 ID

HTTP 方法和網址:

PATCH https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id

JSON 要求主體:

{
  "settings":
  {
    "databaseFlags":
    [
      {
        "name": "flag_name",
        "value": "flag_value"
      }
    ]
  }
}

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

舉例來說,如要為現有資料庫使用設定 general_log 標記:

使用任何要求資料之前,請先替換以下項目:

  • project-id:專案 ID
  • instance-id:執行個體 ID

HTTP 方法和網址:

PATCH https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id

JSON 要求主體:

{
  "settings":
  {
    "databaseFlags":
    [
      {
        "name": "general_log",
        "value": "on"
      }
    ]
  }
}

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

如果資料庫目前已設有標記,請修改前一指令以併入這些標記。PATCH 指令會以要求中指定的值覆寫現有的標記。

將所有旗標清除為預設值

控制台

  1. Google Cloud 控制台中,選取含有要清除所有標記的 Cloud SQL 執行個體的專案。
  2. 開啟執行個體並按一下 [編輯]
  3. 開啟「資料庫標記」區段。
  4. 按一下畫面上所有顯示標記旁的 [X]
  5. 按一下 [儲存] 以儲存變更。

gcloud

清除執行個體中所有標記並轉為預設值:

gcloud sql instances patch INSTANCE_NAME \
--clear-database-flags

系統會提示您將重新啟動執行個體。

REST v1

清除現有執行個體的所有標記:

使用任何要求資料之前,請先替換以下項目:

  • project-id:專案 ID
  • instance-id:執行個體 ID

HTTP 方法和網址:

PATCH https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id

JSON 要求主體:

{
  "settings":
  {
    "databaseFlags": []
  }
}

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

REST v1beta4

清除現有執行個體的所有標記:

使用任何要求資料之前,請先替換以下項目:

  • project-id:專案 ID
  • instance-id:執行個體 ID

HTTP 方法和網址:

PATCH https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id

JSON 要求主體:

{
  "settings":
  {
    "databaseFlags": []
  }
}

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

查看資料庫旗標的現行值

如要檢視 MySQL 系統變數的所有現行值,請使用 mysql 用戶端登入執行個體,然後輸入下列陳述式:

 SHOW VARIABLES;

請注意,您只能變更支援標記的值 (如下所示)。

判斷執行個體已設定哪些資料庫旗標

如要查看 Cloud SQL 執行個體已設定的旗標:

控制台

  1. Google Cloud 控制台中,選取包含 Cloud SQL 執行個體的專案,查看已設定的資料庫標記。
  2. 選取執行個體,開啟「Instance Overview」(執行個體總覽) 頁面。

    在「資料庫標記」區段下方會列出已設定的資料庫標記。

gcloud

取得執行個體狀態:

gcloud sql instances describe INSTANCE_NAME

在輸出中,資料庫標記會列示為 settings 底下的 databaseFlags 集合。如要進一步瞭解輸出內容中的旗標表示法,請參閱執行個體資源表示法

REST v1

列出已針對執行個體設定的標記:

使用任何要求資料之前,請先替換以下項目:

  • project-id:專案 ID
  • instance-id:執行個體 ID

HTTP 方法和網址:

GET https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

在輸出中,找出 databaseFlags 欄位。

REST v1beta4

列出已針對執行個體設定的標記:

使用任何要求資料之前,請先替換以下項目:

  • project-id:專案 ID
  • instance-id:執行個體 ID

HTTP 方法和網址:

GET https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

在輸出中,找出 databaseFlags 欄位。

由 Cloud SQL 管理的旗標

Cloud SQL 會根據執行個體機型調整特定系統旗標。

innodb_buffer_pool_instances
  • db-f1-micro 和 db-g1-small 為 1。
  • 如果 RAM < 7.5 GB,則為 1。
  • 2 (如果 7.5 GB <= RAM < 13 GB)。
  • 4 (如果 RAM 容量介於 13 GB 和 26 GB 之間)。
  • 如果 RAM >= 26 GB,則為 8。

支援的標記

Cloud SQL 中支援的標記是最常要求的 MySQL 標記。系統不支援下列未提及的標記。

對於特定標記,Cloud SQL 支援的值或範圍可能會與對應的 MySQL 參數或選項不同。

除非另外註明,否則標記適用於 Cloud SQL 支援的所有 MySQL 版本。

A | B | C | D | E | F | G | H | I | L | M | N | O | P | Q | R | S | T | U | W

如要進一步瞭解此標記,請參閱「提示」一節。

Cloud SQL 標記 類型
可接受的值與附註
需要重新啟動
嗎?
activate_all_roles_on_login boolean
on | off
default: off
autocommit boolean
on | off
預設:on
auto_increment_increment integer
1 ... 65535
auto_increment_offset integer
1 ... 65535
automatic_sp_privileges boolean
on | off
預設:on
back_log integer
1 ... 65535
default: max_connections
binlog_cache_size integer
4096 ... 9223372036854775807
binlog_expire_logs_seconds integer
086400 (1 day) ... 4294967295 (max value)
預設值為 2592000,相當於 30 天。

如要進一步瞭解此標記,請參閱提示一節。

binlog_group_commit_sync_delay 0 ... 1000000

支援 MySQL 5.7 以上版本

預設值為 0

binlog_group_commit_sync_no_delay_count 0 ... 1000000

支援 MySQL 5.7 以上版本

預設值為 0

binlog_gtid_simple_recovery boolean
on | off
預設:on
binlog_order_commits boolean
on | off
預設:on

如要進一步瞭解此標記,請參閱提示一節。

binlog_row_image enumeration
full (預設)、minimalnoblob
binlog_row_metadata enumeration
fullminimal (預設)
binlog_row_value_options string
PARTIAL_JSON
binlog_rows_query_log_events boolean
on | off
預設:off
binlog_stmt_cache_size 4096 ... 9223372036854775807
binlog_transaction_dependency_history_size integer

如要瞭解如何使用這個旗標和可接受的值,請參閱「設定平行複製功能」。

binlog_transaction_dependency_tracking enumeration

如要瞭解如何使用這個旗標和可接受的值,請參閱「設定平行複製功能」。MySQL 8.4 不支援這個標記。

block_encryption_mode string
aes-keylen-mode
預設值:aes-128-ECB
bulk_insert_buffer_size integer
0 ... 4294967295
default: 8388608
collation_connection string
預設值:
MySQL 8.0 以上版本 - utf8mb4_0900_ai_ci

如要進一步瞭解此標記,請參閱提示一節。

collation_server string
預設值:
MySQL 5.7 - utf8_general_ci
MySQL 8.0 以上版本 - utf8mb4_0900_ai_ci
character_set_client string

預設:
MySQL 5.7:utf8
MySQL 8.0 以上版本:utf8mb4

如要進一步瞭解此標記,請參閱提示一節。

character_set_connection string
預設:
MySQL 5.7:utf8
MySQL 8.0 以上版本:utf8mb4

如要進一步瞭解此標記,請參閱提示一節。

character_set_results string
utf8utf8mb4
預設值:
MySQL 5.7:utf8
MySQL 8.0 以上版本:utf8mb4

如要進一步瞭解此標記,請參閱提示一節。

character_set_server string
utf8utf8mb4 (建議)
check_proxy_users boolean
on | off
預設:off
cloudsql_allow_analyze_table boolean on | off
default: off
cloudsql_iam_authentication boolean on | off
預設:off
適用於 MySQL 5.7 以上版本的 Cloud SQL。
cloudsql_ignore_innodb_encryption boolean on | off
default: off
cloudsql_mysql_audit_data_masking_cmds string
""dqldmlddldclshowcallcreate_udfdrop_functioncreate_procedurecreate_functiondrop_procedurealter_procedurealter_functioncreate_triggerdrop_triggercreate_eventalter_eventdrop_eventcreate_dbdrop_dbalter_dbcreate_userdrop_userrename_useralter_usercreate_tablecreate_indexalter_tabledrop_tabledrop_indexcreate_viewdrop_viewrename_tableupdateinsertinsert_selectdeletetruncatereplacereplace_selectdelete_multiupdate_multiloadselectcall_procedureconnectdisconnectgrantrevoke、、show_triggersshow_create_procshow_create_funcshow_procedure_codeshow_function_codeshow_create_eventshow_eventsshow_create_triggershow_grantsshow_binlog_eventsshow_relaylog_events

預設值:create_useralter_usergrantupdate revoke_all
cloudsql_mysql_audit_data_masking_regex string
max_string_length: 2048
預設:按一下這裡
cloudsql_mysql_audit_log_write_period integer
0...5000 毫秒
預設值:500 毫秒
cloudsql_mysql_audit_max_query_length integer
-1...1073741824
default: -1
cloudsql_vector boolean on | off
預設值:off
cloudsql_vector_max_mem_size integer
1073741824...innodb_buffer_pool_size/2
預設值:以位元組為單位
1073741824
completion_type enumeration
NO_CHAIN (預設)、 CHAINRELEASE
concurrent_insert enumeration
NEVERAUTO (預設) 或 ALWAYS
connect_timeout integer
2 ... 31536000
default: 10
cte_max_recursion_depth integer
0 ... 4294967295
default: 1000
default_authentication_plugin string
mysql_native_password|caching_sha2_password
default_password_lifetime integer 0...65535
default: 0
default_time_zone string
指定時區的方式有兩種:時區偏移量和時區名稱。舉例來說,+00:00 是倫敦 (位於世界標準時間時區) 的時區偏移,Europe/London 則是時區名稱。

您可以使用值指定時區偏移量,範圍從 -12:59+13:00。必須加上前置零。

使用時區名稱時,系統支援自動調整日光節約時間。系統不支援時區偏移。如需 MySQL 適用的 Cloud SQL 支援的時區名稱清單,請參閱這篇文章。您必須在主要執行個體和所有唯讀備用資源上,手動更新這個標記,才能將其納入考量。

如要設定時區,但不想重新啟動 Cloud SQL 執行個體,請使用 set time_zone=timezone_offsettimezone_name 指令,並加上 init_connect 旗標。

default_week_format integer
0 ... 7
default: 0
delay_key_write enumeration
OFFON (預設) 或 ALL
disconnect_on_expired_password boolean on | off
default: on
div_precision_increment integer
0 ... 30
default: 4
end_markers_in_json boolean
on | off
預設:off
eq_range_index_dive_limit integer
0 ... 2147483647
event_scheduler boolean
on | off

如果您正使用 Event Scheduler,請使用「ALWAYS」的 啟用政策設定執行個體,以確保排定的事件可以執行。

如要進一步瞭解此標記,請參閱提示一節。

expire_logs_days integer
0 ... 99
預設值為 0,表示不會自動移除。

注意:MySQL 8.4 不支援這個標記。 請改用 binlog_expire_logs_seconds。如要進一步瞭解此標記,請參閱提示一節。

explicit_defaults_for_timestamp boolean
on | off

flush_time integer
0 ... 31536000
default: 0
foreign_key_checks boolean
on | off
預設:on

如要進一步瞭解此標記,請參閱提示一節。

ft_max_word_len integer
10 ... 252
ft_min_word_len integer
1 ... 16
ft_query_expansion_limit integer
0 ... 1000
ft_stopword_file string
general_log boolean
on | off

如要進一步瞭解一般記錄,請參閱提示一節。

generated_random_password_length integer 5-255
default: 20
group_concat_max_len integer
4 ... 17179869184
gtid_executed_compression_period integer
0 ... 4294967295
預設 (最高 8.0.22 版):1000
預設 (8.0.23 以上版本):0
histogram_generation_max_mem_size integer
1000000 ... 4294967295
default: 20000000
init_connect string
innodb_adaptive_hash_index boolean
on | off
innodb_adaptive_hash_index_parts integer
1 ... 512
innodb_adaptive_max_sleep_delay integer
0 ... 1000000
innodb_autoextend_increment integer
1 ... 1000
innodb_autoinc_lock_mode integer
0 ... 2
innodb_buffer_pool_chunk_size integer
1048576 ... (innodb_buffer_pool_size/innodb_buffer_pool_instances)

這個旗標值取決於 innodb_buffer_pool_sizeinnodb_buffer_pool_instances。MySQL 可以根據這兩個標記自動調整 innodb_buffer_pool_chunk_size 的值。

innodb_buffer_pool_dump_pct integer
1 ... 100
預設值:25
innodb_buffer_pool_dump_at_shutdown boolean
on | off
innodb_buffer_pool_dump_now boolean
on | off

如要進一步瞭解此標記,請參閱「提示」一節。

innodb_buffer_pool_instances integer
1 ... 64
innodb_buffer_pool_load_abort boolean
on | off

如要進一步瞭解此標記,請參閱「提示」一節。

innodb_buffer_pool_load_at_startup boolean
on | off
innodb_buffer_pool_load_now boolean
on | off

如要進一步瞭解此標記,請參閱「提示」一節。

innodb_buffer_pool_size integer

為 MySQL 5.6 設定此旗標時,需要重新啟動執行個體。如要進一步瞭解此標記,請參閱提示一節。

innodb_change_buffer_max_size integer
0 ... 50
innodb_change_buffering string

選項:noneinsertsdeleteschangespurgesall

innodb_checksum_algorithm string

選項:crc32strict_crc32innodbstrict_innodnonestrict_none

innodb_cloudsql_optimized_write boolean

這個旗標僅適用於 Cloud SQL Enterprise Plus 版本的執行個體。 如要進一步瞭解此標記,請參閱提示一節。

innodb_cmp_per_index_enabled boolean
on | off
innodb_commit_concurrency integer
0 ... 1000
innodb_compression_failure_threshold_pct integer
0 ... 100
innodb_compression_level integer
0 ... 9
innodb_compression_pad_pct_max integer
0 ... 75
innodb_concurrency_tickets integer
1 ... 4294967295
innodb_deadlock_detect boolean
on | off

支援 MySQL 5.7 以上版本。

預設:on

innodb_disable_sort_file_cache boolean
on | off
innodb_doublewrite_batch_size integer
0 ... 256
預設值:0
innodb_doublewrite_files integer
2 ... 128
innodb_doublewrite_pages integer
4 ... 512
預設值:64
innodb_file_per_table boolean
on | off

如要進一步瞭解此標記,請參閱提示一節。

innodb_fill_factor integer
10 ... 100
innodb_flush_log_at_timeout double
0.0001... 2700
預設值:1

支援 MySQL 5.7 以上版本。

如要進一步瞭解此標記,請參閱提示一節。

innodb_flush_log_at_trx_commit integer
1, 2
預設值:1

如果升級副本時啟用這個旗標,系統會自動移除該旗標,使升級後的副本預設具備完整耐久性。如要搭配升級的副本使用這個標記,可以在升級後將標記更新至副本。

如要進一步瞭解此標記,請參閱提示一節。

innodb_flush_neighbors enumeration
0 ... 2
預設值:
  • MySQL 5.6: 0
  • MySQL 5.7 以上版本: 2
  • innodb_flush_sync boolean
    on | off
    innodb_ft_aux_table string

    如要進一步瞭解此標記,請參閱提示一節。

    innodb_ft_cache_size integer
    1600000 ... 80000000
    innodb_ft_enable_diag_print boolean
    on | off
    innodb_ft_enable_stopword boolean
    on | off
    innodb_ft_max_token_size integer
    10 ... 252
    innodb_ft_min_token_size integer
    0 ... 16
    innodb_ft_num_word_optimize integer
    1000 ... 10000
    innodb_ft_result_cache_limit integer
    1000000 ... 4294967295
    innodb_ft_server_stopword_table string
    innodb_ft_sort_pll_degree integer
    1 ... 32
    innodb_ft_total_cache_size integer
    32000000 ... 1600000000
    innodb_ft_user_stopword_table string
    innodb_io_capacity integer
    100 ... 100000
    預設值:5000

    如要進一步瞭解如何設定磁碟效能,請參閱「設定磁碟以符合效能需求」中的「E2 VM」表格。

    innodb_io_capacity_max integer
    100 ... 100000
    預設值:10000

    如要進一步瞭解如何設定磁碟效能,請參閱「設定磁碟以符合效能需求」中的「E2 VM」表格。

    innodb_large_prefix boolean
    on | off

    僅在 MySQL 5.6 中受到支援。

    innodb_lock_wait_timeout integer
    1 ... 1073741824
    innodb_log_buffer_size integer
    262144 ... 4294967295
    innodb_log_checksums boolean
    on | off
    預設值:on
    innodb_log_file_size integer
    MySQL 5.6:1048576 ... 274877906944
    MySQL 5.7 以上版本:4194304 ... 274877906944
    innodb_log_spin_cpu_abs_lwm integer
    0 ... 4294967295
    預設值:80
    innodb_log_spin_cpu_pct_hwm integer
    0 ... 100
    預設值:50
    innodb_log_wait_for_flush_spin_hwm integer
    0 ... 4294967295
    預設值:400
    innodb_log_write_ahead_size integer
    512 ... 65536
    預設值:8192
    innodb_lru_scan_depth integer
    100 ... 9223372036854775807
    innodb_max_dirty_pages_pct float
    0 ... 99.99
    default: 90
    innodb_max_dirty_pages_pct_lwm float
    0 ... 99.99
    default: 10
    innodb_max_purge_lag integer
    0 ... 4294967295
    default: 0
    innodb_max_undo_log_size integer
    10485760 ... 9223372036854775807
    預設值:1073741824
    innodb_max_purge_lag_delay integer
    0 ... 10000000
    default: 0
    innodb_monitor_disable string
    innodb_monitor_enable string
    innodb_monitor_reset string
    countermodulepatternall
    innodb_monitor_reset_all enumeration
    有效值:countermodulepatternall
    innodb_old_blocks_pct integer
    5 ... 95
    innodb_old_blocks_time integer
    0 ... 4294967295
    innodb_online_alter_log_max_size integer
    65536 ... 9223372036854775807
    innodb_open_files integer
    100 ... 2147483647
    預設:
    MySQL 5.7:2000
    MySQL 8.0 以上版本:4000
    8.0.28:否
    8.0.27:是
    innodb_optimize_fulltext_only boolean
    on | off
    innodb_page_cleaners integer
    1 ... 64
    MySQL 5.7 以上版本支援這項功能。 如果是 MySQL 5.7 和 8.0,預設值為 4。 如果是 MySQL 8.4,預設值會等於為 innodb_buffer_pool_instances 旗標設定的值。
    innodb_parallel_read_threads integer
    1 ... 256
    default: 4
    innodb_print_all_deadlocks boolean
    on | off
    預設值:off
    innodb_print_ddl_logs boolean
    on | off
    innodb_purge_batch_size integer
    1 ... 5000
    default: 300
    innodb_purge_rseg_truncate_frequency integer
    1 ... 128
    default: 128
    innodb_purge_threads integer
    1 ... 32
    預設值:
  • MySQL 5.6: 1
  • MySQL 5.7 以上版本: 4
  • innodb_random_read_ahead boolean
    on | off
    innodb_read_ahead_threshold integer
    0 ... 64
    innodb_read_io_threads integer
    1 ... 64
    innodb_redo_log_capacity integer
    MySQL 8.0.33 和更早版本:8388608 (8 MB) ... 137438953472 (128 GB) MySQL 8.0.34 和更新版本:8388608 (8 MB) ... 549755813888 (512 GB)

    如要進一步瞭解此標記,請參閱「提示」一節。

    innodb_replication_delay integer
    0 ... 4294967295
    innodb_rollback_on_timeout boolean
    on | off
    innodb_rollback_segments integer
    1 ... 128
    innodb_segment_reserve_factor float
    .03 ... 40
    default: 12.5
    innodb_sort_buffer_size integer
    65536 ... 67108864
    innodb_spin_wait_delay integer
    MySQL 5.7:0 ... 1000000
    MySQL 8.0.13 以上版本:0 ... 1000
    預設:6
    innodb_stats_auto_recalc boolean
    on | off
    innodb_stats_include_delete_marked boolean
    on | off
    預設值:off
    innodb_stats_method enumeration
    nulls_equal | nulls_unequal | nulls_ignored
    innodb_stats_on_metadata boolean
    on | off
    innodb_stats_persistent boolean
    on | off
    innodb_stats_persistent_sample_pages integer
    1 ... 9223372036854775807
    innodb_stats_sample_pages integer
    1 ... 9223372036854775807
    innodb_stats_transient_sample_pages integer
    1 ... 9223372036854775807
    innodb_status_output boolean
    on | off
    innodb_status_output_locks boolean
    on | off
    innodb_strict_mode boolean
    on | off
    innodb_sync_array_size 1 ... 1024

    預設值為 1

    innodb_sync_spin_loops integer
    0 ... 4294967295
    預設值:30
    innodb_table_locks boolean
    on | off
    預設值:on
    innodb_thread_concurrency integer
    0 ... 1000
    innodb_thread_sleep_delay integer
    0 ... 1000000
    innodb_undo_log_truncate boolean
    on | off
    預設值:on
    innodb_use_native_aio boolean
    on | off
    預設值:on
    innodb_write_io_threads integer
    1 ... 64
    interactive_timeout integer
    1 ... 31536000
    internal_tmp_disk_storage_engine enumeration
    INNODB | MYISAM
    預設值:INNODB
    internal_tmp_mem_storage_engine enumeration
    MEMORYTempTable
    join_buffer_size integer
    128 ... 9223372036854775807
    keep_files_on_create boolean
    on | off
    預設:off
    key_buffer_size integer
    4096 ... 4294967295
    default: 8388608
    key_cache_age_threshold integer
    100 ... 9223372036854775807
    default: 300
    key_cache_block_size integer
    512 ... 16384
    default: 1024
    key_cache_division_limit integer
    1 ... 100
    default: 100
    lc_times_names string
    en_US | cs_CZ | da_DK | nl_NL | et_EE | fr_FR | de_DE | el_GR | hu_HU | it_IT | ja_JP | ko_KR | no_NO | nb_NO | pl_PL | pt_PT | ro_RO | ru_RU | sr_RS | sk_SK | es_ES | sv_SE | uk_UA
    預設值:en_US
    local_infile boolean
    on | off
    lock_wait_timeout integer
    1 ... 31536000
    log_bin_trust_function_creators boolean
    on | off
    log_output set
    FILE | TABLE | NONE
    log_error_verbosity integer
    1 ... 3
    預設:
    MySQL 5.7:3
    MySQL 8.0 以上版本:2
    log_queries_not_using_indexes boolean
    on | off
    log_slow_admin_statements boolean
    on | off
    預設值:off
    log_slow_extra boolean
    on | off
    預設值:off
    log_slow_replica_statements boolean
    on | off 預設:off
    log_slow_slave_statements boolean
    on | off 預設值:off
    log_throttle_queries_not_using_indexes integer
    0 ... 9223372036854775807
    log_timestamps string
    "UTC | SYSTEM"
    預設值:UTC
    long_query_time float
    0 ... 30000000

    如有需要,Cloud SQL 可讓使用者將此標記設定為小於 1。

    如果也啟用 log_queries_not_using_indexes 旗標,系統可能會顯示時間少於此處指定時間的查詢。

    lower_case_table_names 5.7 | 8.0 integer
    01
    預設值:0

    如果這個旗標使用預設值 0,表格和資料庫名稱就會區分大小寫。設為 1 時,資料表和資料庫名稱不區分大小寫。

    如果是 MySQL 5.7 執行個體,您可以隨時變更這個旗標的值。如果需要變更此標記的值,請確定瞭解變更將對現有表格與資料庫造成哪些影響。

    如果是 MySQL 8.0 以上版本的執行個體,您只能在建立執行個體時,將這個旗標的值設為所需值。設定後即無法變更。此外,您無法變更現有執行個體的這個旗標值。

    為 MySQL 5.7、MySQL 8.0 或 MySQL 8.4 執行個體建立唯讀副本時,副本會從主要執行個體繼承這個旗標值。

    mandatory_roles string role name
    default: empty string
    master_verify_checksum boolean
    on | off 預設值:off
    max_allowed_packet integer
    16384 ... 1073741824

    如果 sql_mode=TRADITIONAL 或 sql_mode=STRICT_ALL_TABLES,這個值必須是 1024 的倍數。

    max_binlog_cache_size integer
    4096 ... 4294967296
    default: 4294967296
    max_binlog_size integer
    4096 ... 1073741824
    max_binlog_stmt_cache_size integer
    4096 ... 4294967296
    default: 4294967296
    max_connect_errors integer
    1 ... 9223372036854775807
    default: 100
    max_connections integer
    1 ... 100000
    max_digest_length integer
    0 ... 1048576
    max_error_count integer
    0 ... 65535
    default:
    MySQL 5.7 or lower: 64
    MySQL 8.0 and later: 1024
    max_execution_time integer
    0 ... 9223372036854775807
    max_heap_table_size integer
    16384 ... 67108864

    如要進一步瞭解此標記,請參閱提示一節。

    max_join_size integer
    16 ... 9223372036854775807
    max_length_for_sort_data integer
    4 ... 8388608
    max_points_in_geometry integer
    3 ... 1048576
    max_prepared_stmt_count integer
    0 ... 1048576
    max_seeks_for_key integer
    1 ... 9223372036854775807
    max_sort_length integer
    4 ... 8388608
    max_sp_recursion_depth integer
    0 ... 255
    max_user_connections integer
    0 ... 4294967295
    max_write_lock_count integer
    1 ... 9223372036854775807
    min_examined_row_limit integer
    0 ... 4294967295
    default: 0
    myisam_data_pointer_size integer
    2...7
    預設值:6
    myisam_max_sort_file_size integer
    0...9223372036853727232
    預設值:9223372036853727232
    myisam_mmap_size integer
    7...9223372036854775807
    預設值:9223372036854775807
    myisam_sort_buffer_size integer
    4096...4294967295
    預設值:8388608
    myisam_stats_method string
    "nulls_unequal, nulls_equal, nulls_ignored"
    預設值:nulls_unequal
    myisam_use_mmap boolean
    on | off
    預設:off
    mysql_native_password_proxy_users boolean
    on | off
    預設:off
    net_buffer_length integer
    1024 ... 1048576
    default: 16384
    net_read_timeout integer
    30 ... 4294967295
    net_retry_count integer
    10 ... 4294967295
    net_write_timeout integer
    60 ... 4294967295
    ngram_token_size integer
    1 ... 10
    default: 2
    optimizer_prune_level integer
    0 ... 1
    optimizer_search_depth integer
    0 ... 62
    optimizer_switch multi-value repeated string

    如要進一步瞭解多值標記,請參閱「提示」一節。

    optimizer_trace multi-value repeated string
    enabled=onenabled=offone_line=onone_line=off

    如要進一步瞭解多值標記,請參閱「提示」一節。

    optimizer_trace_features multi-value repeated string

    如要進一步瞭解多值標記,請參閱「提示」一節。

    optimizer_trace_max_mem_size integer
    0 ... 9223372036854775807
    optimizer_trace_offset integer
    -9223372036854775808 ... 9223372036854775807
    parser_max_mem_size integer
    10000000 ... 9223372036854775807
    password_history integer 0-4294967295
    default: 0
    password_require_current boolean on | off
    預設值:off
    password_reuse_interval integer 0-4294967295
    default: 0
    performance_schema boolean
    on | off

    預設值:off,適用於 MySQL 5.6、5.7、8.0 和 8.4,前提是執行個體 RAM 小於 15 GB。

    預設值:on,適用於 MySQL 8.0 以上版本,前提是執行個體 RAM 大於 15 GB

    如要進一步瞭解 performance_schema 標記,請參閱「提示」一節。

    performance_schema_accounts_size integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱「提示」一節。

    performance_schema_digests_size integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱「提示」一節。

    performance_schema_error_size integer
    0 ... 1048576
    performance_schema_events_stages_history_long_size integer
    -1 ... 1048576
    performance_schema_events_stages_history_size integer
    -1 ... 1024

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_events_statements_history_long_size integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_events_statements_history_size integer
    -1 ... 1024

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_events_transactions_history_long_size integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_events_transactions_history_size integer
    -1 ... 1024

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_events_waits_history_long_size integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_events_waits_history_size integer
    -1 ... 1024

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_hosts_size integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_cond_classes integer
    0 ... 256

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_cond_instances integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_digest_length integer
    0 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_digest_sample_age integer
    0 ... 1048576
    default: 60
    performance_schema_max_file_classes integer
    0 ... 256

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_file_handles integer
    0 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_file_instances integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_index_stat integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_memory_classes integer
    0 ... 1024

    如要進一步瞭解 performance_schema 標記,請參閱「提示」一節。

    performance_schema_max_metadata_locks integer
    -1 ... 104857600

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_mutex_classes integer
    0 ... 256

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_mutex_instances integer
    -1 ... 104857600

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_prepared_statements_instances integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_program_instances integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_rwlock_classes integer
    0 ... 256

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_rwlock_instances integer
    -1 ... 104857600

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_socket_classes integer
    0 ... 256

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_socket_instances integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_sql_text_length integer
    0 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_stage_classes integer
    0 ... 256

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_statement_classes integer
    0 ... 256

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_statement_stack integer
    1 ... 256

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_table_handles integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_table_instances integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_table_lock_stat integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_thread_classes integer
    0 ... 256

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_max_thread_instances integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_session_connect_attrs_size integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_setup_actors_size integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_setup_objects_size integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    performance_schema_users_size integer
    -1 ... 1048576

    如要進一步瞭解 performance_schema 標記,請參閱提示一節。

    preload_buffer_size integer
    1024 ... 1073741824
    default: 32768
    query_alloc_block_size integer
    1024 ... 4294967295
    query_cache_limit integer
    0 ... 223338299392

    MySQL 5.7.20 已淘汰查詢快取,MySQL 8.0 則已移除這項功能,因此這個標記不適用於 MySQL 8.0 以上版本。

    query_cache_min_res_unit integer
    0 ... 9223372036854775807

    MySQL 5.7.20 已淘汰查詢快取,MySQL 8.0 則已移除這項功能,因此這個標記不適用於 MySQL 8.0 以上版本。

    query_cache_size integer
    0 ... 223338299392

    MySQL 5.7.20 已淘汰查詢快取,MySQL 8.0 則已移除這項功能,因此這個標記不適用於 MySQL 8.0 以上版本。

    query_cache_type enumeration
    0 ... 2

    MySQL 5.7.20 已淘汰查詢快取,MySQL 8.0 則已移除這項功能,因此這個標記不適用於 MySQL 8.0 以上版本。

    query_cache_wlock_invalidate boolean
    on | off

    MySQL 5.7.20 已淘汰查詢快取,MySQL 8.0 則已移除這項功能,因此這個標記不適用於 MySQL 8.0 以上版本。

    query_prealloc_size integer
    8192 ... 9223372036854775807
    range_alloc_block_size integer
    4096 ... 4294967295
    range_optimizer_max_mem_size integer
    0 ... 9223372036854775807
    read_buffer_size integer
    8192 ... 2147483647
    read_only boolean
    on | off

    對備用資源沒有影響。

    read_rnd_buffer_size integer
    1 ... 2147483647
    regexp_stack_limit integer
    0 ... 2147483647
    regexp_time_limit integer
    0 ... 2147483647
    default: 32
    replica_checkpoint_group integer
    32 ... 524280
    預設值為 512。

    如果副本未啟用多執行緒,這個旗標就不會影響副本。

    replica_checkpoint_period integer
    1 ... 4294967295
    預設值為 300。

    單位為毫秒。

    replica_compressed_protocol boolean
    on | off
    replica_net_timeout integer
    1 ... 31536000

    單位為秒。

    replica_parallel_type enumeration
    DATABASELOGICAL_CLOCK
    預設值:
    MySQL 8.0.26 或更早版本:DATABASE
    MySQL 8.0.27 或更新版本:LOGICAL_CLOCK

    如要瞭解如何使用這個旗標和可接受的值,請參閱「設定平行複製功能」。

    replica_parallel_workers integer

    如要瞭解如何使用這個旗標和可接受的值,請參閱「設定平行複製功能」。

    replica_pending_jobs_size_max integer

    如要瞭解如何使用這個旗標和可接受的值,請參閱「設定平行複製功能」。

    replica_preserve_commit_order boolean

    如要瞭解如何使用這個旗標和可接受的值,請參閱「設定平行複製功能」。

    replica_skip_errors string
    預設值:OFF

    如要進一步瞭解此標記,請參閱提示一節。

    replica_sql_verify_checksum boolean
    on | off
    replica_transaction_retries integer
    0 ... 9223372036854775807
    replica_type_conversions String
    values: ALL_LOSSY, ALL_NON_LOSSY, ALL_SIGNED, ALL_UNSIGNED
    replicate_do_db string

    如要進一步瞭解如何使用這個旗標,請參閱「複製篩選器」一節。

    replicate_do_table string

    如要進一步瞭解如何使用這個旗標,請參閱「複製篩選器」一節。

    replicate_ignore_db string

    如要進一步瞭解如何使用這個旗標,請參閱「複製篩選器」一節。

    replicate_ignore_table string

    如要進一步瞭解如何使用這個旗標,請參閱「複製篩選器」一節。

    replicate_wild_do_table string

    如要進一步瞭解如何使用這個旗標,請參閱「複製篩選器」一節。

    replicate_wild_ignore_table string

    如要進一步瞭解如何使用這個旗標,請參閱「複製篩選器」一節。

    rpl_read_size integer
    8192 ... 4294959104
    default: 8192
    schema_definition_cache integer
    256 ... 524288
    default: 256
    session_track_gtids string
    OFF | OWN_GTID | ALL_GTIDS
    預設值:OFF
    session_track_schema boolean
    on | off
    預設值:on
    session_track_state_change boolean
    on | off
    預設值:off
    session_track_transaction_info string
    OFF | STATE | CHARACTERISTICS
    預設值:OFF
    sha256_password_proxy_users boolean
    on | off
    預設:off
    show_create_table_verbosity boolean
    on | off
    預設值:off
    show_compatibility_56 boolean
    on | off

    僅支援 MySQL 5.7。

    skip_character_set_client_handshake boolean
    on | off
    預設:off
    skip_show_database flag
    on | off
    slave_checkpoint_group integer
    32 ... 524280
    預設值為 512。

    如果副本未啟用多執行緒,這個旗標就不會影響副本。

    slave_checkpoint_period integer
    1 ... 4294967295
    預設值為 300。

    單位為毫秒。

    slave_compressed_protocol
    slave_net_timeout integer
    1 ... 31536000

    單位為秒。

    slave_parallel_type enumeration
    DATABASELOGICAL_CLOCK
    預設值:
    MySQL 8.0.26 或更早版本:DATABASE
    MySQL 8.0.27 或更新版本:LOGICAL_CLOCK

    如要瞭解如何使用這個旗標和可接受的值,請參閱「設定平行複製功能」。

    slave_parallel_workers integer

    如要瞭解如何使用這個旗標和可接受的值,請參閱「設定平行複製功能」。

    slave_preserve_commit_order boolean

    如要瞭解如何使用這個旗標和可接受的值,請參閱「設定平行複製功能」。

    slave_pending_jobs_size_max integer

    如要瞭解如何使用這個旗標和可接受的值,請參閱「設定平行複製功能」。

    slave_skip_errors string
    預設值:OFF

    如要進一步瞭解此標記,請參閱提示一節。

    slave_sql_verify_checksum boolean
    on | off
    slave_transaction_retries integer
    0 ... 9223372036854775807
    slave_type_conversions string
    values: ALL_LOSSY, ALL_NON_LOSSY, ALL_SIGNED, ALL_UNSIGNED
    slow_launch_time Integer
    0 ... 31536000
    預設值:2
    slow_query_log boolean
    on | off

    如要進一步瞭解慢速查詢記錄,請參閱提示一節。

    sort_buffer_size integer
    32768 ... 9223372036854775807
    source_verify_checksum boolean
    on | off
    預設值:off
    sql_mode string

    如需瞭解允許的值,包括合併模式 (例如 ANSI),請參閱 MySQL 說明文件中的「伺服器 SQL 模式」。系統不支援 NO_DIR_IN_CREATE

    MySQL 適用的 Cloud SQL 不支援 sql_mode 旗標的空白值。請將這個旗標設為 NO_ENGINE_SUBSTITUTION 模式,而非使用空值。

    sql_require_primary_key boolean
    on | off
    預設值:off
    sql_select_limit integer 0...18446744073709551615
    預設值:18446744073709551615

    如要進一步瞭解此標記,請參閱提示一節。