【ComputeEngine】CentOS6でのMySQLの外部公開


Google Compute EngineでCentOS6のMySQLの外部公開の設定を行ったのでそのメモ。
ComputeEngineは月間無料枠もあるし、最安プランなら月5ドル程度なのでかなり良いと思ってます。

① MySQLで接続ユーザーの権限設定を行う
「Linux(CentOS)のMySQLへ外部接続する | 俺の開発研究所」
http://itmemo.net-luck.com/linux-centos-mysql-remote/

② CentOSでiptablesでポートを公開する
※ portが3306のとき

#iptablesの設定を編集
$ sudo vi /etc/sysconfig/iptables

# HTTP
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -jcreate database ACCEPT

#iptablesの再起動

$ sudo  /etc/rc.d/init.d/iptables restart

③ ComputeEngineのファイアウォール設定を変更する
「Google Compute Engineのファイヤーウォールを理解する #gcpja | Developers.IO」
http://dev.classmethod.jp/cloud/gce-firewall/

ソースIP
0.0.0.0/0
ポート
tcp:3306