<ahref="http://www.ktsuge.com/blog/2008/01/19/mysql-server-%E3%81%B8%E5%A4%96%E9%83%A8%E3%83%9B%E3%82%B9%E3%83%88%E3%81%8B%E3%82%89%E3%81%AE%E6%8E%A5%E7%B6%9A%E8%A8%B1%E5%8F%AF/"onclick="__gaTracker('send', 'event', 'outbound-article', 'http://www.ktsuge.com/blog/2008/01/19/mysql-server-%E3%81%B8%E5%A4%96%E9%83%A8%E3%83%9B%E3%82%B9%E3%83%88%E3%81%8B%E3%82%89%E3%81%AE%E6%8E%A5%E7%B6%9A%E8%A8%B1%E5%8F%AF/', 'MySQL Server へ外部ホストからの接続許可');"target="_blank">MySQL Server へ外部ホストからの接続許可</a>
<blockquotetitle="404 Not Found"cite="http://www.ktsuge.com/blog/2008/01/19/mysql-server-%E3%81%B8%E5%A4%96%E9%83%A8%E3%83%9B%E3%82%B9%E3%83%88%E3%81%8B%E3%82%89%E3%81%AE%E6%8E%A5%E7%B6%9A%E8%A8%B1%E5%8F%AF/">
<p>
調べてみると、以下の箇所を修正する必要がある様だ。
</p>
<ol>
<li>
MySQL Serverの設定ファイルmy.cnfを開き、[mysqld]の項目以下の、bind-addressを探す。
</li>
<li>
bind-addressを、コメントアウトする。
</li>
</ol>
<p>
修正し終わったら、MySQL Serverを再起動すると、外部ホストからも接続可能となる。
</p>
<p>
<cite><ahref="http://www.ktsuge.com/blog/2008/01/19/mysql-server-%E3%81%B8%E5%A4%96%E9%83%A8%E3%83%9B%E3%82%B9%E3%83%88%E3%81%8B%E3%82%89%E3%81%AE%E6%8E%A5%E7%B6%9A%E8%A8%B1%E5%8F%AF/"onclick="__gaTracker('send', 'event', 'outbound-article', 'http://www.ktsuge.com/blog/2008/01/19/mysql-server-%E3%81%B8%E5%A4%96%E9%83%A8%E3%83%9B%E3%82%B9%E3%83%88%E3%81%8B%E3%82%89%E3%81%AE%E6%8E%A5%E7%B6%9A%E8%A8%B1%E5%8F%AF/', '404 Not Found');"target="_blank">404 Not Found</a></cite>
</p>
</blockquote>
<p>
というわけで、 /etc/mysql にある my.cnf を編集します。
</p>
<preclass="syntax-highlight">
kazu634@srv634% sudo vi my.cnf /etc/mysql <spanclass="synStatement">[</span><spanclass="synConstant">7304</span><spanclass="synStatement">]</span>
kazu634@srv634% mysql -uroot -pxxxxxxxx ~ [<spanclass="synConstant">7291</span>]
Welcome <spanclass="synSpecial">to</span> the MySQL monitor. Commands <spanclass="synSpecial">end</span><spanclass="synSpecial">with</span> ; <spanclass="synStatement">or</span> \g.
Your MySQL connection id <spanclass="synSpecial">is</span><spanclass="synConstant">398</span>
Server version: <spanclass="synConstant">5.0</span>.<spanclass="synConstant">75</span>-0ubuntu10.<spanclass="synConstant">2</span> (Ubuntu)
<spanclass="synSpecial">Type</span><spanclass="synConstant">'help;'</span><spanclass="synStatement">or</span><spanclass="synConstant">'\h'</span><spanclass="synSpecial">for</span> help. <spanclass="synSpecial">Type</span><spanclass="synConstant">'\c'</span><spanclass="synSpecial">to</span> clear the buffer.
mysql> use mysql;
Reading <spanclass="synSpecial">table</span> information <spanclass="synSpecial">for</span> completion <spanclass="synSpecial">of</span><spanclass="synSpecial">table</span><spanclass="synStatement">and</span><spanclass="synSpecial">column</span> names
You can turn off this feature <spanclass="synSpecial">to</span> get a quicker startup <spanclass="synSpecial">with</span> -A
~ on kazu634 <spanclass="synStatement">[</span><spanclass="synConstant">518</span><spanclass="synStatement">]</span> $: mysql <spanclass="synSpecial">-h</span> srv634 <spanclass="synSpecial">-uroot</span><spanclass="synSpecial">-p</span>
-bash: mysql: command not found
~ on kazu634 <spanclass="synStatement">[</span><spanclass="synConstant">519</span><spanclass="synStatement">]</span> $: mysql5 <spanclass="synSpecial">-h</span> srv634 <spanclass="synSpecial">-uroot</span><spanclass="synSpecial">-p</span>
Enter password:
Welcome to the MySQL monitor. Commands end with <spanclass="synStatement">;</span> or \g.
Your MySQL connection id is <spanclass="synConstant">35</span>
Server version: <spanclass="synConstant">5</span>.<spanclass="synConstant"></span>.<spanclass="synConstant">75</span>-0ubuntu10.<spanclass="synConstant">2</span><spanclass="synStatement">(</span>Ubuntu<spanclass="synStatement">)</span>
Type <spanclass="synStatement">'</span><spanclass="synConstant">help;</span><spanclass="synStatement">'</span> or <spanclass="synStatement">'</span><spanclass="synConstant">\h</span><spanclass="synStatement">'</span><spanclass="synStatement">for</span><spanclass="synStatement">help</span>. Type <spanclass="synStatement">'</span><spanclass="synConstant">\c</span><spanclass="synStatement">'</span> to <spanclass="synStatement">clear</span> the current input statement.
mysql<spanclass="synStatement">></span> use shop<spanclass="synStatement">;</span>
Reading table information <spanclass="synStatement">for</span> completion of table and column names
You can turn off this feature to get a quicker startup with <spanclass="synStatement">-A</span>
Database changed
mysql<spanclass="synStatement">></span> show tables<spanclass="synStatement">;</span>