EC2 turn on MySQL remote access

Source: Internet
Author: User
Tags mysql in

Recently installed MySQL on the Amazon Cloud host, want to remote access, the results can not be accessed anyway. After stepping on a few pits, finally the visit succeeded, here to do a record: How to turn on remote access after MySQL is installed on EC2.

First, the problems encountered

To remotely access MySQL on EC2, always tip:
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 up the EC2 firewall

EC2 The default firewall is to block all traffic, so in addition to the other necessary rules in EC2 's scurity groups, add an ingress traffic rule: TCP的3306端口的任意源IP的连接都允许 .

2. Set user's access in MySQL

MySQL is only allowed to be accessed from the native computer by default, and to enable remote access, execute the following command in terminal, respectively:

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

This will enable MySQL to be accessed from any IP.

3. Set the binding IP in MySQL
sudo vim /etc/mysql/my.cnf

Then change bind-address 127.0.0.1 to bind-address 0.0.0.0 , so EC2 IP no matter how changes, can be remotely accessed.

4. Restart MySQL
sudo /etc/init.d/mysql restart
Third, reference

MySQL initializes the root password and allows remote access
Connect to MySQL in Amazon EC2 from a remote server

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

EC2 turn on MySQL remote access

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.