Friday, December 26, 2008

cant connect to mysql from client on remote machine, mysql running on aws

error messages you can get are
Error 2003: Can't Connect to MySQL server on 'hostname'

1) enable the firewall for amazon aws ec2 instance.
ec2-authorize default -p 3306
3306 is default port on which mysql runs. If you are running mysql on different port like 3307 or 3309 enable that.

2) in mysql/my.cnf which is mysql config file.

comment out following line which allows connection only from localhost.

bind_address=127.0.0.1


3) log on to mysql with root from local machine

GRANT ALL ON *.* TO 'user'@'ipadd' identified by 'pwd';

ipadd is ip address of machine from which you are trying to connect to mysql server
user and password are auth info.

useful links

http://forge.mysql.com/wiki/Error2003-CantConnectToMySQLServer

1 comment:

Anonymous said...

Thanks for the clear, simple instructions. That's exactly what I was looking for.

The only thing I would recommend is to provide a host name in the ec2-authorize command. If no source host, group or subnet is provided, requests from any source address will be honored. That is a bad security breach.