Search This Blog

Wednesday, October 5, 2011

Mysql with remote access using Amazon AMI (Without EBS)

I thought this would be easy however it took me a day and a little bit of digging around.
Here is the few simple steps to set up Mysql on Amazon (Without EBS)

* Pick a basic Fedora AMI
ami-5647a33f (http://aws.amazon.com/amis/AWS/517 , Basic Fedora Core 8)
* Start your machine, make sure you have a security group defined (let us call mysql-dev)

* ssh to the amazon box
* yum install mysql-server (install mysql)
* /etc/init.d/mysqld start (start mysql)


Steps to change password for root user (Highly Recommended)
* Login mysql -u root
* Change the root password
SET PASSWORD FOR root@localhost=PASSWORD('new_password');
SET PASSWORD FOR root@'127.0.0.1'=PASSWORD('new_password');
SET PASSWORD FOR root@'ip-*-*-*-*'=PASSWORD('new_password');
( Note here you need to set your internal ip from amazon)
* Restart mysql and test new password
* /etc/init.d/mysqld restart
* mysql -u root -p
* 'new_password'

Steps to set up remote access for root user
* To set up remote access from any host for root user
* update user set host='%' where user='root' and host='ip-*-*-*-*';
* flush priveleges;
* Enable 3306 port for the instance (I use elastic-fox for the given amazon instance)

Test the mysql remote access connection
* hostname :
* port: 3306
* user : root
* password : 'new_password'

NOTE : The hostname here is the public DNS name for your amazon box
Example:- It will be ec2-*-*-*-*.compute-1.amazonaws.

Hope this helps you in your mysql setup, let me know if you have questions/issues

Thanks
Ravi