EC2 enables MySql remote access and ec2mysql Remote Access

Source: Internet
Author: User

EC2 enables MySql remote access and ec2mysql Remote Access

Recently, MySql was installed on an Amazon cloud host and cannot be accessed remotely. After several pitfalls, the access was successful. Here we will record how to enable remote access after MySql is installed on EC2.

I. Problems Encountered

To remotely access MySql on EC2, the following message is displayed:
ERROR 2003 (HY000): Can't connect to MySQL server on 'xx.xx.xx.xx' (111)
Or
Host 'xx.xx.xx.xx' is not allowed to connect to this MySQL server

Ii. solution 1. Set the EC2 Firewall

EC2's default firewall blocks all traffic. Therefore, in addition to other necessary rules in EC2's Scurity Groups, you must add an ingress traffic rule:Any source IP connection of port 3306 of TCP is allowed..

2. Set User Access in MySql

By default, MySql only allows access from the local machine. To enable remote access, run the following commands in Terminal:

mysql -u root -puse mysqlupdate user set Host='%' where User='root'

In this way, you can access MySql from any IP address.

3. Bind IP addresses in MySql
sudo vim /etc/mysql/my.cnf

Thenbind-address 127.0.0.1Changebind-address 0.0.0.0In this way, no matter how the EC2 IP address changes, it can be remotely accessed.

4. Restart MySql
sudo /etc/init.d/mysql restart
Iii. References

Mysql initializes the root password and allows remote access
Connect to mysql on Amazon EC2 from a remote server

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.