Allowing MySQL on Amazon’s EC2 to accept remote connections

转载自:https://kylegoslin.wordpress.com/2012/05/18/109/

Amazon’s EC2 is a really great platform for well, everything!

I recently got a LAMP server setup some development, instead of having a LAMP server running locally. It is always a nice idea to see your code in an actual production environment, not local setting.

One little hitch people will come across after setting up a LAMP server on the EC2, is how do you allow remote connections to your mysql database. 

It is actually really simple, just a few small extra steps are needed!

Ok, it’s get started…

  1. Head over to your myself configuration. file. located at /etc/mysql/my.cnf and look for the “bind-address” this should have a value of 0.0.0.0
  2. Restart your mysql server
  3. Next we need to open the port on the EC2. Log into your user account and on the left hand side, head down to “Security Groups“. Look for the security group that is associated with your EC2 instance. (You can find the name of the security group for your instance to the right hand side of the instance name on main instance listing page). Once you have found the security group, click on it and under the “Inbound” tab you will see a list of port rules for the inbound traffic.Here you can open the MySQL Port (3306 by default unless you changed it). You will see a list of predefined ports for services that you can select to quickly add. Once of these is for MySQL (Others include HTTP, SSH etc).Don’t forget to click “Apply Rule Option” at the bottom when you are finished.
  4. Finally, we need to make a non “root” user account that will be used to access the database remotely. To access mysql from the terminal type: mysql -u root -pAnd you will then be prompted for your password. Once you have opened MySQL run the following command: GRANT ALL PRIVILEGES ON *.* TO bob@’%’ identified by “yourpasswordhere”;By running this command, you will be giving access to a user called bob, with the password yourpasswordhere and it will be accessable from any location.

And your done!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值