DebianにMySQLで外部ホストから接続できるメモ

1.3306ポートを開放
vim /etc/iptables.conf
追記
-A INPUT -p tcp –dport 3306 -j ACCEPT
再起動
iptables-restore < /etc/iptables.conf

 

2.mysqlのIPアドレスを修正
vim /etc/mysql/my.cnf
修正前
bind-address = 127.0.0.1
修正後
bind-address = 0.0.0.0

3.root権限を修正
use mysql;
update user set password=PASSWORD('new password’) where user=’root’;
FLUSH PRIVILEGES;

権限設定
GRANT ALL ON *.* TO 'root’@’%’ IDENTIFIED BY 'newpassword’;
exit;

4.再起動
/etc/init.d/mysql restart

Linux

Posted by arkgame