InfoHeap
Tech tutorials, tips, tools and more
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

AWS and EC2

  • AWS benefits
  • Broken sudoers file
  • EBS and reliability/durability
  • EC2 api tools on Ubuntu
  • Install wordpress AWS Classic Ubuntu
  • Linux instance on AWS Classic
  • Mysql access
  • Mysql service and micro instance
  • Route53 as DNS
  • Upgrade Linux micro instance to small
  • ssh automation
 
  • Home
  • > Tutorials
  • > AWS and EC2

How to allow mysql access on AWS/EC2 from a specific IP

By admin | Last updated on Jun 12, 2016

If you have mysql server on AWS EC2 instances, you may need remote access to mysql server form a specific IP. Note that if you need access between two AWS instances, it is better to use security groups. Here are the steps to allow access from a specific IP:

  • Open /etc/mysql/my.cnf on the instance where you have mysql server change
    bind-address           = 127.0.0.1
    to
    bind-address            = 0.0.0.0
  • Goto security group settings on mysql hosting EC2 instance (on https://console.aws.amazon.com/ec2) and add the following:
    3306  (MYSQL) CLIENT_IP/32
    (CLIENT_IP is ip of the IP from where you want to access mysql from)
    aws_mysql_security_group_settings
  • Once this is done, click on apply rule changes in security group for these changes to take effect.
    aws_mysql_security_group_apply_rule_changes
  • To test if everything is fine, run this from client machine:
    telnet MYSQL_INSTANCE_IP 3306.
    If you see the following, then it means the port access stuff is fine.
    Connected to mysqlserver.com.
    Escape character is ‘^]’.
  • After this you will need to create a mysql user (avoid using root for remote login) and grant it appropriate privileges. e.g. you can create a “writer” user for host “%” and that will let write connect to mysql from other hosts.

Note that this article was written for AWS classic. In case of AWS vpc, instructions may be slightly different. And these instructions should only be used when you are sure that the accessing IP is static and never changes. Otherwise you may have to update the settings every time IP changes which is error prone.

Suggested posts:

  1. How to connect to mysql server using ssh port forwarding
  2. Use x2go to access remote Ubuntu Linux
  3. How to install wordpress on Amazon AWS-EC2 Classic Ubuntu Linux micro instance
  4. How to find mysql query rate on Linux
  5. WordPress mysql query to get all posts with a specific custom field
  6. How to fix mysql service stopping intermittently on AWS micro instance
  7. How to add a user on Linux with sudo access
  8. Block directory access using htaccess 404
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged AWS and EC2, Cloud, Devops Interview Questions, Mysql, Tutorials

Follow InfoHeap

facebook
twitter
googleplus
  • Browse site
  • Article Topics
  • Article archives
  • Recent Articles
  • Contact Us
  • Omoney
Popular Topics: AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries

Copyright © 2022 InfoHeap.

Powered by WordPress