Using Console
Using CLI
gcloud sql instances list
gcloud sql instances patch [INSTANCE_NAME] --maintenance-window-day [DAY_OF_WEEK] --maintenance-window-hour [HOUR_OF_DAY]
Replace [INSTANCE_NAME] with the name of your SQL instance, [DAY_OF_WEEK] with the day of the week on which you want to schedule maintenance, and [HOUR_OF_DAY] with the hour of the day on which you want to schedule maintenance.
For example, to schedule maintenance for an instance named “my-sql-instance” every Sunday at 2:00 AM UTC, run the following command:
gcloud sql instances patch my-sql-instance --maintenance-window-day SUN --maintenance-window-hour 02:00
gcloud sql instances describe [INSTANCE_NAME]
Replace [INSTANCE_NAME] with the name of your SQL instance. The output will show the maintenance window details.
Using Python
<path_to_service_account_key_file>
and <your_project_id>
with the actual values for your GCP project.