LoginSignup
56
51

More than 5 years have passed since last update.

踏み台サーバ越しにあるMySQLにSequel Proでつなぎにいく

Posted at

背景

Sequel ProはMySQLをGUIでいじれるのでいろいろ便利です。
もちろんSQL生で叩いてもいいですが、効率面からもSequel Proのほうが早かったりします。
以下は、Sequel Proの画面です。

gui.png

ローカルにあるMySQLは簡単につなげるのですが、その時に困るのが、踏み台など経由した先にあるMySQLにつなぐ場合です。
この場合、以下のように設定すると繋げれるようになります。

環境

server.png

ローカルのMacからAppサーバであるApp001に、踏み台を経由して以下のコマンドで、つなぎに行けることを前提としています。
なおapp001.xxxはApp001のホスト名です。

ssh app001.xxx

上記のようにつなぐには~/.ssh/configに以下のような設定をします。
fumidai.domainが踏み台のホスト名です(図ではHost: Aのこと)

Host fumidai
    HostName fumidai.domain
    User user_name
    IdentityFile ~/.ssh/id_rsa

Host app001.xxx
    User user_name
    IdentityFile ~/.ssh/id_rsa
    ProxyCommand ssh fumidai -W %h:%p

Sequel Proの設定

以下のように設定します。

sequel_pro.png

注意

このようにすればSequel Proで本番サーバにつなげたりしますが、念のため、アカウントはRead Onlyで設定しておくといいです。
なんでもできるアカウントだと間違って行を消したときなど取り返しがつかない事になるからです。

56
51
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
56
51