kikukawa's diary

都内で活動するシステムエンジニアが書いてます。 興味を持った技術やハマったポイント、自分用メモをつけてます。 最近はweb中心

Ubuntu mysqlの環境設定

phpからmysqlにつなぐための設定
mysqliを使いたい場合も同じ

sudo aptitude install mysql-client
sudo aptitude intstall php-5-mysql

Serve側の設定

Windowsなど外部から接続できるようにする。
/etc/mysql/my.cnfを編集

sudo vim /etc/mysql/my.cnf

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1

下記の部分をコメントアウト。もしくは許可したいものを追加

bind-address = 127.0.0.1

再起動する
reloadじゃだめだった。

sudo /etc/init.d/mysql restart