Cloud SQL 雲端建置資料庫
Google Cloud Platform Cloud SQL
Cloud SQL 就是GCP雲端計算平台上的資料庫相關服務,提供完善的資料庫操作Google Cloud SDK相關建置指令,也可以透過Google Cloud Console UI進行設置。
實際操作
透過 Google Cloud Console UI設置
Step.1 登入GCP帳戶後進到Cloud SQL的選項
Step.2 選擇Create Instance建立執行個體
Step.3 選擇資料庫引擎
Step.4 填寫配置
資料庫名稱、密碼、資料庫版本、Region、以及其他額外選項
接者等待Cloud SQL instance顯示綠勾勾就建置完成了
UI設置真的非常簡單呢
透過 Google Cloud SDK 進行設置
Step.1 Google Cloud SDK 設置
畢竟不在GCP內部操作,所以需要綁到你的專案裏頭
1 | gcloud init |
Step.2 建置Cloud SQL(這裡使用Postgresql)
建立名子叫postgre的 postgresql資料庫管理系統14版,地區asia-east2
tier是指計費方案
1 | gcloud sql instances create postgre \ |
資料庫就建置完成了
Step.3 建立資料庫 webalbum
需要給與參數 –instance 選定剛剛建置好的資料庫管理系統
1 | gcloud sql databases create webalbum --instance postgre |
測試webalbum是否被建立
1 | gcloud sql databases list --instance webalbum |
Step.4 設置Root密碼
1 | gcloud sql users set-password root \ |