Closed10
ローカルから CloudSQL に接続する

このスクラップについて
ローカルでプロキシサーバーを起動して CloudSQL に接続できるようにする手順をまとめる。

過去にやったことがある
ここから漁ろう。

こっちだった

関連ドキュメント

インスタンスを探す
コマンド
# 現在のプロジェクトを確認
gcloud config get-value project
# プロジェクトの一覧
gcloud config configurations list
# プロジェクトの切り替え
gcloud config configurations activate xxxx
# インスタンス一覧
gcloud sql instances list
# 接続名の表示
gcloud sql instances describe yyyy | grep connectionName

プロキシ?プロクシ?
ドキュメントではプロキシだったのでこちらに統一する。

プロキシサーバー起動
コマンド
cloud-sql-proxy --address 0.0.0.0 --port 13306 xxxx:yyyy:zzzz

別ターミナル起動
コマンド
mysql -u root -p -h 127.0.0.1 -P 13306

おわりに
はじめての場合はインストールや初期設定が必要となる。
詳しくは下記の投稿をご覧ください。
このスクラップは2023/08/04にクローズされました